Zelda Classic Coverage Report


Directory: src/
File: src/qst.cpp
Date: 2023-11-06 12:17:09
Exec Total Coverage
Lines: 8553 12538 68.2%
Functions: 93 128 72.7%
Branches: 5726 10657 53.7%

Line Branch Exec Source
1 #include "allegro/file.h"
2 #include "base/util.h"
3 #include "base/zapp.h"
4 #include "base/qrs.h"
5 #include "base/cpool.h"
6 #include "base/autocombo.h"
7 #include "base/packfile.h"
8 #include "base/dmap.h"
9 #include "base/combo.h"
10 #include "base/msgstr.h"
11 #include <filesystem>
12 #include <stdio.h>
13 #include <cstring>
14 #include <string>
15 #include <map>
16 #include <vector>
17 #include <assert.h>
18 #include <fmt/format.h>
19
20
21 #include "metadata/sigs/devsig.h.sig"
22 #include "metadata/sigs/compilersig.h.sig"
23 #include "metadata/versionsig.h"
24 #include "base/zc_alleg.h"
25 #include "base/zdefs.h"
26 #include "base/colors.h"
27 #include "tiles.h"
28 #include "base/zsys.h"
29 #include "qst.h"
30 #include "defdata.h"
31 #include "subscr.h"
32 #include "zc/replay.h"
33 #include "zc/zc_custom.h"
34 #include "sfx.h"
35 #include "md5.h"
36 #include "zinfo.h"
37 #include "zc/ffscript.h"
38 #include "particles.h"
39 #include "dialog/alert.h"
40 #include "base/misctypes.h"
41 #include "base/initdata.h"
42
43 //FFScript FFCore;
44 extern FFScript FFCore;
45 extern ZModule zcm;
46 extern zcmodule moduledata;
47 extern uint8_t __isZQuest;
48 extern sprite_list guys, items, Ewpns, Lwpns, chainlinks, decorations;
49 extern particle_list particles;
50 extern void setZScriptVersion(int32_t s_version);
51 //FFSCript FFEngine;
52
53 static bool read_ext_zinfo = false, read_zinfo = false;
54 static bool loadquest_report = false;
55 static char const* loading_qst_name = NULL;
56 static byte loading_qst_num = 0;
57 static byte subscr_mode = ssdtMAX;
58 dword loading_tileset_flags = 0;
59
60 int32_t First[MAX_COMBO_COLS]={0},combo_alistpos[MAX_COMBO_COLS]={0},combo_pool_listpos[MAX_COMBO_COLS]={0},combo_auto_listpos[MAX_COMBO_COLS]={0};
61 map_and_screen map_page[MAX_MAPPAGE_BTNS]= {{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}};
62
63 #ifdef _MSC_VER
64 #define strncasecmp _strnicmp
65 #endif
66
67 #ifndef _AL_MALLOC
68 #define _AL_MALLOC(a) _al_malloc(a)
69 #define _AL_FREE(a) _al_free(a)
70 #endif
71
72 using std::string;
73 using std::pair;
74
75 // extern bool debug;
76 extern int32_t hero_animation_speed; //lower is faster animation
77 extern byte *colordata;
78 //extern byte *tilebuf;
79 extern tiledata *newtilebuf;
80 extern byte *trashbuf;
81 extern itemdata *itemsbuf;
82 extern wpndata *wpnsbuf;
83 extern comboclass *combo_class_buf;
84 extern guydata *guysbuf;
85 extern ZCHEATS zcheats;
86 extern char palnames[MAXLEVELS][17];
87 extern int32_t memrequested;
88 extern char *byte_conversion(int32_t number, int32_t format);
89 extern char *byte_conversion2(int32_t number1, int32_t number2, int32_t format1, int32_t format2);
90 string zScript;
91 117 std::map<int32_t, script_slot_data > ffcmap;
92 117 std::map<int32_t, script_slot_data > globalmap;
93 117 std::map<int32_t, script_slot_data > genericmap;
94 117 std::map<int32_t, script_slot_data > itemmap;
95 117 std::map<int32_t, script_slot_data > npcmap;
96 117 std::map<int32_t, script_slot_data > ewpnmap;
97 117 std::map<int32_t, script_slot_data > lwpnmap;
98 117 std::map<int32_t, script_slot_data > playermap;
99 117 std::map<int32_t, script_slot_data > dmapmap;
100 117 std::map<int32_t, script_slot_data > screenmap;
101 117 std::map<int32_t, script_slot_data > itemspritemap;
102 117 std::map<int32_t, script_slot_data > comboscriptmap;
103 117 std::map<int32_t, script_slot_data > subscreenmap;
104 void free_newtilebuf();
105 bool combosread=false;
106 bool mapsread=false;
107 bool fixffcs=false;
108 bool fixpolsvoice=false;
109
110 const std::string script_slot_data::DEFAULT_FORMAT = "%s %s";
111 const std::string script_slot_data::INVALID_FORMAT = "%s --%s";
112 const std::string script_slot_data::DISASSEMBLED_FORMAT = "%s ++%s";
113 const std::string script_slot_data::ZASM_FORMAT = "%s ==%s";
114
115 char qstdat_string[2048] = { 0 };
116
117 static zinfo* load_tmp_zi = NULL;
118
119 int32_t memDBGwatch[8]= {0,0,0,0,0,0,0,0}; //So I can monitor memory crap
120 const byte clavio[9]={97,109,111,110,103,117,115,0};
121
122 //enum { qe_OK, qe_notfound, qe_invalid, qe_version, qe_obsolete,
123 // qe_missing, qe_internal, qe_pwd, qe_match, qe_minver };
124
125 const char *qst_error[] =
126 {
127 "OK","File not found","Invalid quest file",
128 "Version not supported","Obsolete version",
129 "Missing new data" , /* but let it pass in ZQuest */
130 "Internal error occurred", "Invalid password",
131 "Doesn't match saved game", "Save file is for older version of quest; please start new save",
132 "Out of memory", "File Debug Mode", "Canceled", "", "No quest assigned"
133 };
134
135 //for legacy quests -DD
136 enum { ssiBOMB, ssiSWORD, ssiSHIELD, ssiCANDLE, ssiLETTER, ssiPOTION, ssiLETTERPOTION, ssiBOW, ssiARROW, ssiBOWANDARROW, ssiBAIT, ssiRING, ssiBRACELET, ssiMAP,
137 ssiCOMPASS, ssiBOSSKEY, ssiMAGICKEY, ssiBRANG, ssiWAND, ssiRAFT, ssiLADDER, ssiWHISTLE, ssiBOOK, ssiWALLET, ssiSBOMB, ssiHCPIECE, ssiAMULET, ssiFLIPPERS,
138 ssiHOOKSHOT, ssiLENS, ssiHAMMER, ssiBOOTS, ssiDIVINEFIRE, ssiDIVINEESCAPE, ssiDIVINEPROTECTION, ssiQUIVER, ssiBOMBBAG, ssiCBYRNA, ssiROCS, ssiHOVERBOOTS,
139 ssiSPINSCROLL, ssiCROSSSCROLL, ssiQUAKESCROLL, ssiWHISPRING, ssiCHARGERING, ssiPERILSCROLL, ssiWEALTHMEDAL, ssiHEARTRING, ssiMAGICRING, ssiSPINSCROLL2,
140 ssiQUAKESCROLL2, ssiAGONY, ssiSTOMPBOOTS, ssiWHIMSICALRING, ssiPERILRING, ssiMAX
141 };
142
143 static byte deprecated_rules[QUESTRULES_NEW_SIZE];
144
145
146 void delete_combo_aliases()
147 {
148 for(int32_t j(0); j<256; j++)
149 {
150 if(combo_aliases[j].combos != NULL)
151 {
152 delete[] combo_aliases[j].combos;
153 combo_aliases[j].combos=NULL;
154 }
155
156 if(combo_aliases[j].csets != NULL)
157 {
158 delete[] combo_aliases[j].csets;
159 combo_aliases[j].csets=NULL;
160 }
161 }
162
163 }
164
165 char *byte_conversion(int32_t number, int32_t format)
166 {
167 static char num_str[40];
168
169 if(format==-1) //auto
170 {
171 format=1; //bytes
172
173 if(number>1024)
174 {
175 format=2; //kilobytes
176 }
177
178 if(number>1024*1024)
179 {
180 format=3; //megabytes
181 }
182
183 if(number>1024*1024*1024)
184 {
185 format=4; //gigabytes (dude, what are you doing?)
186 }
187 }
188
189 switch(format)
190 {
191 case 1: //bytes
192 sprintf(num_str,"%db",number);
193 break;
194
195 case 2: //kilobytes
196 sprintf(num_str,"%.2fk",float(number)/1024);
197 break;
198
199 case 3: //megabytes
200 sprintf(num_str,"%.2fM",float(number)/(1024*1024));
201 break;
202
203 case 4: //gigabytes
204 sprintf(num_str,"%.2fG",float(number)/(1024*1024*1024));
205 break;
206
207 default:
208 abort();
209 break;
210 }
211
212 return num_str;
213 }
214
215 1404 char *byte_conversion2(int32_t number1, int32_t number2, int32_t format1, int32_t format2)
216 {
217 static char num_str1[40];
218 static char num_str2[40];
219 static char num_str[80];
220
221
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1404 times.
1404 if(format1==-1) //auto
222 {
223 1404 format1=1; //bytes
224
225
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1404 times.
1404 if(number1>1024)
226 {
227 1404 format1=2; //kilobytes
228 1404 }
229
230
2/2
✓ Branch 0 taken 936 times.
✓ Branch 1 taken 468 times.
1404 if(number1>1024*1024)
231 {
232 468 format1=3; //megabytes
233 468 }
234
235
1/2
✓ Branch 0 taken 1404 times.
✗ Branch 1 not taken.
1404 if(number1>1024*1024*1024)
236 {
237 format1=4; //gigabytes (dude, what are you doing?)
238 }
239 1404 }
240
241
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1404 times.
1404 if(format2==-1) //auto
242 {
243 1404 format2=1; //bytes
244
245
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1404 times.
1404 if(number2>1024)
246 {
247 1404 format2=2; //kilobytes
248 1404 }
249
250
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1404 times.
1404 if(number2>1024*1024)
251 {
252 1404 format2=3; //megabytes
253 1404 }
254
255
1/2
✓ Branch 0 taken 1404 times.
✗ Branch 1 not taken.
1404 if(number2>1024*1024*1024)
256 {
257 format2=4; //gigabytes (dude, what are you doing?)
258 }
259 1404 }
260
261
2/5
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 936 times.
✓ Branch 3 taken 468 times.
✗ Branch 4 not taken.
1404 switch(format1)
262 {
263 case 1: //bytes
264 sprintf(num_str1,"%db",number1);
265 break;
266
267 case 2: //kilobytes
268 936 sprintf(num_str1,"%.2fk",float(number1)/1024);
269 936 break;
270
271 case 3: //megabytes
272 468 sprintf(num_str1,"%.2fM",float(number1)/(1024*1024));
273 468 break;
274
275 case 4: //gigabytes
276 sprintf(num_str1,"%.2fG",float(number1)/(1024*1024*1024));
277 break;
278
279 default:
280 abort();
281 break;
282 }
283
284
1/5
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1404 times.
✗ Branch 4 not taken.
1404 switch(format2)
285 {
286 case 1: //bytes
287 sprintf(num_str2,"%db",number2);
288 break;
289
290 case 2: //kilobytes
291 sprintf(num_str2,"%.2fk",float(number2)/1024);
292 break;
293
294 case 3: //megabytes
295 1404 sprintf(num_str2,"%.2fM",float(number2)/(1024*1024));
296 1404 break;
297
298 case 4: //gigabytes
299 sprintf(num_str2,"%.2fG",float(number2)/(1024*1024*1024));
300 break;
301
302 default:
303 abort();
304 break;
305 }
306
307 1404 sprintf(num_str, "%s/%s", num_str1, num_str2);
308 1404 return num_str;
309 }
310
311 char *ordinal(int32_t num)
312 {
313 static const char *ending[4] = {"st","nd","rd","th"};
314 static char ord_str[8];
315
316 char *end;
317 int32_t t=(num%100)/10;
318 int32_t n=num%10;
319
320 if(n>=1 && n<4 && t!=1)
321 end = (char *)ending[n-1];
322 else
323 end = (char *)ending[3];
324
325 sprintf(ord_str,"%d%s",num%10000,end);
326 return ord_str;
327 }
328
329 int32_t get_version_and_build(PACKFILE *f, word *version, word *build)
330 {
331 int32_t ret;
332 *version=0;
333 *build=0;
334 byte temp_map_count=map_count;
335 byte temp_midi_flags[MIDIFLAGS_SIZE];
336 memcpy(temp_midi_flags, midi_flags, MIDIFLAGS_SIZE);
337
338 zquestheader tempheader;
339
340 if(!f)
341 {
342 return qe_invalid;
343 }
344
345 ret=readheader(f, &tempheader);
346
347 if(ret)
348 {
349 return ret;
350 }
351
352 map_count=temp_map_count;
353 memcpy(midi_flags, temp_midi_flags, MIDIFLAGS_SIZE);
354 *version=tempheader.zelda_version;
355 *build=tempheader.build;
356 return 0;
357 }
358
359
360 bool find_section(PACKFILE *f, int32_t section_id_requested)
361 {
362
363 if(!f)
364 {
365 return false;
366 }
367
368 int32_t section_id_read;
369 bool catchup=false;
370 word dummy;
371 byte tempbyte;
372 char tempbuf[65536];
373
374
375 switch(section_id_requested)
376 {
377 case ID_RULES:
378 case ID_STRINGS:
379 case ID_MISC:
380 case ID_TILES:
381 case ID_COMBOS:
382 case ID_CSETS:
383 case ID_MAPS:
384 case ID_DMAPS:
385 case ID_DOORS:
386 case ID_ITEMS:
387 case ID_WEAPONS:
388 case ID_COLORS:
389 case ID_ICONS:
390 case ID_INITDATA:
391 case ID_GUYS:
392 case ID_MIDIS:
393 case ID_CHEATS:
394 break;
395
396 default:
397 al_trace("Bad section requested!\n");
398 return false;
399 break;
400 }
401
402 dword section_size;
403
404 //section id
405 if(!p_mgetl(&section_id_read,f))
406 {
407 return false;
408 }
409
410 while(!pack_feof(f))
411 {
412 switch(section_id_read)
413 {
414 case ID_RULES:
415 case ID_STRINGS:
416 case ID_MISC:
417 case ID_TILES:
418 case ID_COMBOS:
419 case ID_CSETS:
420 case ID_MAPS:
421 case ID_DMAPS:
422 case ID_DOORS:
423 case ID_ITEMS:
424 case ID_WEAPONS:
425 case ID_COLORS:
426 case ID_ICONS:
427 case ID_INITDATA:
428 case ID_GUYS:
429 case ID_MIDIS:
430 case ID_CHEATS:
431 catchup=false;
432 break;
433
434 default:
435 break;
436 }
437
438
439 while(catchup)
440 {
441 //section id
442 section_id_read=(section_id_read<<8);
443
444 if(!p_getc(&tempbyte,f))
445 {
446 return false;
447 }
448
449 section_id_read+=tempbyte;
450 }
451
452 if(section_id_read==section_id_requested)
453 {
454 return true;
455 }
456 else
457 {
458 //section version info
459 if(!p_igetw(&dummy,f))
460 {
461 return false;
462 }
463
464 if(!p_igetw(&dummy,f))
465 {
466 return false;
467 }
468
469 //section size
470 if(!p_igetl(&section_size,f))
471 {
472 return false;
473 }
474
475 //pack_fseek(f, section_size);
476 while(section_size>65535)
477 {
478 pfread(tempbuf,65535,f);
479 tempbuf[65535]=0;
480 section_size-=65535;
481 }
482
483 if(section_size>0)
484 {
485 pfread(tempbuf,section_size,f);
486 tempbuf[section_size]=0;
487 }
488 }
489
490 //section id
491 if(!p_mgetl(&section_id_read,f))
492 {
493 return false;
494 }
495 }
496
497 return false;
498 }
499
500
501
502
503
504 bool valid_zqt(PACKFILE *f)
505 {
506
507 //word tiles_used;
508 //word combos_used;
509 //open the file
510 //PACKFILE *f = pack_fopen(path, F_READ_PACKED);
511 if(!f)
512 return false;
513
514 //for now, everything else is valid
515 return true;
516
517 /*int16_t version;
518 byte build;
519
520 //read the version and make sure it worked
521 if(!p_igetw(&version,f))
522 {
523 goto error;
524 }
525
526 //read the build and make sure it worked
527 if(!p_getc(&build,f))
528 goto error;
529
530 //read the tile info and make sure it worked
531 if(!p_igetw(&tiles_used,f))
532 {
533 goto error;
534 }
535
536 for (int32_t i=0; i<tiles_used; i++)
537 {
538 if(!pfread(trashbuf,tilesize(tf4Bit),f))
539 {
540 goto error;
541 }
542 }
543
544 //read the combo info and make sure it worked
545 if(!p_igetw(&combos_used,f))
546 {
547 goto error;
548 }
549 for (int32_t i=0; i<combos_used; i++)
550 {
551 if(!pfread(trashbuf,sizeof(newcombo),f))
552 {
553 goto error;
554 }
555 }
556
557 //read the palette info and make sure it worked
558 for (int32_t i=0; i<48; i++)
559 {
560 if(!pfread(trashbuf,newpdTOTAL,f))
561 {
562 goto error;
563 }
564 }
565 if(!pfread(trashbuf,sizeof(palcycle)*256*3,f))
566 {
567 goto error;
568 }
569 for (int32_t i=0; i<MAXLEVELS; i++)
570 {
571 if(!pfread(trashbuf,PALNAMESIZE,f))
572 {
573 goto error;
574 }
575 }
576
577 //read the sprite info and make sure it worked
578 for (int32_t i=0; i<MAXITEMS; i++)
579 {
580 if(!pfread(trashbuf,sizeof(itemdata),f))
581 {
582 goto error;
583 }
584 }
585
586 for (int32_t i=0; i<MAXWPNS; i++)
587 {
588 if(!pfread(trashbuf,sizeof(wpndata),f))
589 {
590 goto error;
591 }
592 }
593
594 //read the triforce pieces info and make sure it worked
595 for (int32_t i=0; i<8; ++i)
596 {
597 if(!p_getc(&trashbuf,f))
598 {
599 goto error;
600 }
601 }
602
603
604
605 //read the game icons info and make sure it worked
606 for (int32_t i=0; i<4; ++i)
607 {
608 if(!p_igetw(&trashbuf,f))
609 {
610 goto error;
611 }
612 }
613
614 //read the misc colors info and map styles info and make sure it worked
615 if(!pfread(trashbuf,sizeof(zcolors),f))
616 {
617 goto error;
618 }
619
620 //read the template screens and make sure it worked
621 byte num_maps;
622 if(!p_getc(&num_maps,f))
623 {
624 goto error;
625 }
626 for (int32_t i=0; i<TEMPLATES; i++)
627 {
628 if(!pfread(trashbuf,sizeof(mapscr),f))
629 {
630 goto error;
631 }
632 }
633 if (num_maps>1) //dungeon templates
634 {
635 for (int32_t i=0; i<TEMPLATES; i++)
636 {
637 if(!pfread(trashbuf,sizeof(mapscr),f))
638 {
639 goto error;
640 }
641 }
642 }
643
644 //yay! it worked! close the file and say everything was ok.
645 pack_fclose(f);
646 return true;
647
648 error:
649 pack_fclose(f);
650 return false;*/
651 }
652
653 bool valid_zqt(const char *filename)
654 {
655 PACKFILE *f=NULL;
656 bool isvalid;
657 int32_t error;
658 f=open_quest_file(&error, filename, false);
659
660 if(!f)
661 {
662 // setPackfilePassword(NULL);
663 return false;
664 }
665
666 isvalid=valid_zqt(f);
667
668 clear_quest_tmpfile();
669 pack_fclose(f);
670
671 // setPackfilePassword(NULL);
672 return isvalid;
673 }
674
675 /*
676 .qst file history
677
678 .qst files have always been compressed using allegro's packfiles.
679
680 At some point, an encoding layer was added. The two layers look like this:
681
682 1) The top layer is from us. See decode_file_007.
683 [0-24] Preamble "Zelda Classic Quest File"
684 [25-28] Initial decoding seed value.
685 [29-X] Allegro-compressed payload (AKA "packed" file), but XOR'd based on seed value
686 [last 4] Checksum
687
688 2) The bottom layer is a "compressed packed file" from Allegro 4. The entire payload
689 is XOR'd with a password (datapwd). Once that is undone, the first four bytes are "slh!",
690 followed by a lzss compressed representation of the payload (from allergo' packfile compression).
691 The oldest quests skip the password part.
692
693 Simply, the job of this function is to peel away the top layer.
694
695 With this second layer of encryption, the data isn't any more secure, and adds a significant delay
696 in opening and saving files. There is no version field, so they decryption key is
697 found via trial-by-error (very slow!)
698
699 There are other file types of interest:
700 - .zqt: quest template files, skips top-layer encryption pass
701 - .qsu: "unencoded" (and uncompressed) files; skips encryption and compression (also makes the longtan password moot)
702 - .qu?: same as above. automated backup files
703 - .qb?: same as above. automated backup files
704 - .qt?: compressed and encrypted (or not encrypted, as of May 2023)
705
706 May 2023: .qst files are now saved without the top layer encoding, and no allegro packfile password. The first bytes of these
707 files are now "slh!.AG ZC Enhanced Quest File".
708 The following command will take an existing qst file and upgrade it: `./zquest -unencrypt-qst <input> <output>`
709 */
710 131 PACKFILE *open_quest_file(int32_t *open_error, const char *filename, bool show_progress)
711 {
712
1/2
✓ Branch 0 taken 131 times.
✗ Branch 1 not taken.
131 if (show_progress)
713 {
714 box_start(1, "Loading Quest", get_zc_font(font_lfont), font, true);
715 }
716
717 131 auto unencrypted_result = try_open_maybe_legacy_encoded_file(filename, ENC_STR, nullptr, QH_NEWIDSTR, QH_IDSTR);
718
2/2
✓ Branch 0 taken 128 times.
✓ Branch 1 taken 3 times.
131 if (unencrypted_result.decoded_pf)
719 128 return unencrypted_result.decoded_pf;
720
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if (unencrypted_result.not_found)
721 {
722 *open_error = qe_notfound;
723 return nullptr;
724 }
725
726 // Everything below here is legacy code - recently saved quest files will have
727 // returned by now.
728 // The only replay qst file that is still using this legacy encoding is `link_to_the_zelda.qst`.
729
730 // Note: although this is primarily for loading .qst files, it can also handle all of the
731 // file types mentioned in the comment above. No need to be told if the file being loaded
732 // is encrypted or compressed, we can do some simple and fast checks to determine how to load it.
733 3 bool top_layer_compressed = unencrypted_result.top_layer_compressed;
734 3 bool compressed = unencrypted_result.compressed;
735 3 bool encrypted = unencrypted_result.encrypted;
736
737 char tmpfilename[L_tmpnam];
738 3 temp_name(tmpfilename);
739 char percent_done[30];
740 3 int32_t current_method=0;
741
742 PACKFILE *f;
743 3 const char *passwd= encrypted ? datapwd : "";
744
745 // oldquest flag is set when an unencrypted qst file is suspected.
746 3 bool oldquest = false;
747 int32_t ret;
748
749
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(strcmp(filename, "default.qst")!=0)
750 {
751 3 box_out(filename);
752 3 }
753 else
754 {
755 box_out("new quest"); // Or whatever
756 }
757 3 box_out("...");
758 3 box_eol();
759 3 box_eol();
760
761
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(encrypted)
762 {
763 3 box_out("Decrypting...");
764 3 box_save_x();
765 3 ret = decode_file_007(filename, tmpfilename, ENC_STR, ENC_METHOD_MAX-1, top_layer_compressed, passwd);
766
767
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(ret)
768 {
769 switch(ret)
770 {
771 case 1:
772 box_out("error.");
773 box_eol();
774 box_end(true);
775 *open_error=qe_notfound;
776 return NULL;
777
778 case 2:
779 box_out("error.");
780 box_eol();
781 box_end(true);
782 *open_error=qe_internal;
783 return NULL;
784 // be sure not to delete tmpfilename now...
785 }
786
787 if(ret==5) //old encryption?
788 {
789 current_method++;
790 sprintf(percent_done, "%d%%", (current_method*100)/ENC_METHOD_MAX);
791 box_out(percent_done);
792 box_load_x();
793 ret = decode_file_007(filename, tmpfilename, ENC_STR, ENC_METHOD_211B9, strstr(filename, ".dat#")!=NULL, passwd);
794 }
795
796 if(ret==5) //old encryption?
797 {
798 current_method++;
799 sprintf(percent_done, "%d%%", (current_method*100)/ENC_METHOD_MAX);
800 box_out(percent_done);
801 box_load_x();
802 ret = decode_file_007(filename, tmpfilename, ENC_STR, ENC_METHOD_192B185, strstr(filename, ".dat#")!=NULL, passwd);
803 }
804
805 if(ret==5) //old encryption?
806 {
807 current_method++;
808 sprintf(percent_done, "%d%%", (current_method*100)/ENC_METHOD_MAX);
809 box_out(percent_done);
810 box_load_x();
811 ret = decode_file_007(filename, tmpfilename, ENC_STR, ENC_METHOD_192B105, strstr(filename, ".dat#")!=NULL, passwd);
812 }
813
814 if(ret==5) //old encryption?
815 {
816 current_method++;
817 sprintf(percent_done, "%d%%", (current_method*100)/ENC_METHOD_MAX);
818 box_out(percent_done);
819 box_load_x();
820 ret = decode_file_007(filename, tmpfilename, ENC_STR, ENC_METHOD_192B104, strstr(filename, ".dat#")!=NULL, passwd);
821 }
822
823 if(ret)
824 {
825 oldquest = true;
826 passwd="";
827 }
828 }
829
830 3 box_out("okay.");
831 3 box_eol();
832 3 }
833 else
834 {
835 oldquest = true;
836 }
837
838 3 box_out("Opening...");
839
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 f = pack_fopen_password(oldquest ? filename : tmpfilename, compressed ? F_READ_PACKED : F_READ, passwd);
840
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(!f)
841 {
842 if((compressed==1)&&(errno==EDOM))
843 {
844 f = pack_fopen_password(oldquest ? filename : tmpfilename, F_READ, passwd);
845 }
846
847 if(!f)
848 {
849 if(!oldquest)
850 {
851 delete_file(tmpfilename);
852 }
853 box_out("error.");
854 box_eol();
855 box_end(true);
856 *open_error=qe_invalid;
857 return NULL;
858 }
859 }
860
861
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if(!oldquest)
862 {
863 3 delete_file(tmpfilename);
864 3 }
865
866 3 box_out("okay.");
867 3 box_eol();
868
869 3 return f;
870 131 }
871
872 PACKFILE *open_quest_template(zquestheader *Header, char *deletefilename, bool validate)
873 {
874 char *filename;
875 PACKFILE *f=NULL;
876 int32_t open_error=0;
877
878 strcpy(qstdat_string, "modules/classic/default.qst");
879 if(Header->templatepath[0]==0)
880 {
881 filename=(char *)malloc(2048);
882 strcpy(filename, qstdat_string);
883 }
884 else
885 {
886 // TODO: should be safe to remove this, no one seems to use custom quest templates.
887 filename=Header->templatepath;
888 }
889
890 f=open_quest_file(&open_error, filename, false);
891
892 if(Header->templatepath[0]==0)
893 {
894 free(filename);
895 }
896
897 if(!f)
898 {
899 return NULL;
900 }
901
902 if(validate)
903 {
904 if(!valid_zqt(f))
905 {
906 jwin_alert("Error","Invalid Quest Template",NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
907 pack_fclose(f);
908 clear_quest_tmpfile();
909 return NULL;
910 }
911 }
912
913 return f;
914 }
915
916 bool init_section(zquestheader *Header, int32_t section_id, miscQdata *Misc, zctune *tunes, bool validate)
917 {
918 // We absolutely do not support loading from a template file to initialize data outside the editor.
919 // TODO: move this code into zq/
920 if (get_app_id() != App::zquest) return false;
921
922 combosread=false;
923 mapsread=false;
924 fixffcs=false;
925
926 switch(section_id)
927 {
928 case ID_RULES:
929 case ID_STRINGS:
930 case ID_MISC:
931 case ID_TILES:
932 case ID_COMBOS:
933 case ID_CSETS:
934 case ID_MAPS:
935 case ID_DMAPS:
936 case ID_DOORS:
937 case ID_ITEMS:
938 case ID_WEAPONS:
939 case ID_COLORS:
940 case ID_ICONS:
941 case ID_INITDATA:
942 case ID_GUYS:
943 case ID_MIDIS:
944 case ID_CHEATS:
945 case ID_ITEMDROPSETS:
946 case ID_FAVORITES:
947 break;
948
949 default:
950 return false;
951 break;
952 }
953
954 int32_t ret;
955 word version, build;
956 PACKFILE *f=NULL;
957
958 char deletefilename[1024];
959 deletefilename[0]=0;
960
961 //why is this here?
962 /*
963 if(colordata==NULL)
964 return false;
965 */
966
967 //setPackfilePassword(datapwd);
968 f=open_quest_template(Header, deletefilename, validate);
969
970 if(!f) //no file, nothing to delete
971 {
972 // setPackfilePassword(NULL);
973 return false;
974 }
975
976 ret=get_version_and_build(f, &version, &build);
977
978 if(ret||(version==0))
979 {
980 pack_fclose(f);
981 clear_quest_tmpfile();
982
983 if(deletefilename[0])
984 {
985 delete_file(deletefilename);
986 }
987
988 // setPackfilePassword(NULL);
989 return false;
990 }
991
992 if(!find_section(f, section_id))
993 {
994 al_trace("Can't find section!\n");
995 pack_fclose(f);
996 clear_quest_tmpfile();
997
998 if(deletefilename[0])
999 {
1000 delete_file(deletefilename);
1001 }
1002
1003 //setPackfilePassword(NULL);
1004 return false;
1005 }
1006
1007 switch(section_id)
1008 {
1009 case ID_RULES:
1010 //rules
1011 ret=readrules(f, Header);
1012 break;
1013
1014 case ID_STRINGS:
1015 //strings
1016 ret=readstrings(f, Header);
1017 break;
1018
1019 case ID_MISC:
1020 //misc data
1021 ret=readmisc(f, Header, Misc);
1022 break;
1023
1024 case ID_TILES:
1025 //tiles
1026 ret=readtiles(f, newtilebuf, Header, version, build, 0, NEWMAXTILES, true);
1027 break;
1028
1029 case ID_COMBOS:
1030 //combos
1031 clear_combos();
1032 ret=readcombos(f, Header, version, build, 0, MAXCOMBOS);
1033 combosread=true;
1034 break;
1035
1036 case ID_COMBOALIASES:
1037 //combos
1038 ret=readcomboaliases(f, Header, version, build);
1039 break;
1040
1041 case ID_CSETS:
1042 //color data
1043 ret=readcolordata(f, Misc, version, build, 0, newerpdTOTAL);
1044 break;
1045
1046 case ID_MAPS:
1047 //maps
1048 ret=readmaps(f, Header);
1049 mapsread=true;
1050 break;
1051
1052 case ID_DMAPS:
1053 //dmaps
1054 ret=readdmaps(f, Header, version, build, 0, MAXDMAPS);
1055 break;
1056
1057 case ID_DOORS:
1058 //door combo sets
1059 ret=readdoorcombosets(f, Header);
1060 break;
1061
1062 case ID_ITEMS:
1063 //items
1064 ret=readitems(f, version, build);
1065 break;
1066
1067 case ID_WEAPONS:
1068 //weapons
1069 ret=readweapons(f, Header);
1070 break;
1071
1072 case ID_COLORS:
1073 //misc. colors
1074 ret=readmisccolors(f, Header, Misc);
1075 break;
1076
1077 case ID_ICONS:
1078 //game icons
1079 ret=readgameicons(f, Header, Misc);
1080 break;
1081
1082 case ID_INITDATA:
1083 //initialization data
1084 ret=readinitdata(f, Header);
1085 break;
1086
1087 case ID_GUYS:
1088 //guys
1089 ret=readguys(f, Header);
1090 break;
1091
1092 case ID_MIDIS:
1093 //midis
1094 ret=readtunes(f, Header, tunes);
1095 break;
1096
1097 case ID_CHEATS:
1098 //cheat codes
1099 ret=readcheatcodes(f, Header);
1100 break;
1101
1102 case ID_ITEMDROPSETS:
1103 //item drop sets
1104 // Why is this one commented out?
1105 //ret=readitemdropsets(f, (int32_t)version, (word)build);
1106 break;
1107
1108 case ID_FAVORITES:
1109 // favorite combos and aliases
1110 ret=readfavorites(f, version, build);
1111 break;
1112
1113 default:
1114 ret=-1;
1115 break;
1116 }
1117
1118 pack_fclose(f);
1119 clear_quest_tmpfile();
1120
1121 if(deletefilename[0])
1122 {
1123 delete_file(deletefilename);
1124 }
1125
1126 //setPackfilePassword(NULL);
1127 if(!ret)
1128 {
1129 return true;
1130 }
1131
1132 return false;
1133 }
1134
1135 bool init_tiles(bool validate, zquestheader *Header)
1136 {
1137 return init_section(Header, ID_TILES, NULL, NULL, validate);
1138 }
1139
1140 bool init_combos(bool validate, zquestheader *Header)
1141 {
1142 return init_section(Header, ID_COMBOS, NULL, NULL, validate);
1143 }
1144
1145 bool init_colordata(bool validate, zquestheader *Header, miscQdata *Misc)
1146 {
1147 return init_section(Header, ID_CSETS, Misc, NULL, validate);
1148 }
1149
1150 131 void init_spritelists()
1151 {
1152
2/2
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 38 times.
131 if(FFCore.quest_format[vZelda] < 0x255)
1153 {
1154 93 guys.setMax(255);
1155 93 items.setMax(255);
1156 93 Ewpns.setMax(255);
1157 93 Lwpns.setMax(255);
1158 93 chainlinks.setMax(255);
1159 93 decorations.setMax(255);
1160 93 particles.setMax(255);
1161 93 }
1162 else
1163 {
1164 38 guys.setMax(255);
1165 38 items.setMax(255);
1166 38 Ewpns.setMax(255);
1167 38 Lwpns.setMax(255);
1168 38 chainlinks.setMax(255);
1169 38 decorations.setMax(255);
1170 38 particles.setMax(255*((255*4)+1)); //255 per sprite that can use particles; guys, items, ewpns, lwpns, +HERO
1171 }
1172 131 }
1173
1174 117 bool reset_items(bool validate, zquestheader *Header)
1175 {
1176 117 bool ret = true;
1177
1/2
✓ Branch 0 taken 117 times.
✗ Branch 1 not taken.
117 if (get_app_id() == App::zquest)
1178 ret = init_section(Header, ID_ITEMS, NULL, NULL, validate);
1179
1180
2/2
✓ Branch 0 taken 117 times.
✓ Branch 1 taken 29952 times.
30069 for(int32_t i=0; i<MAXITEMS; i++) reset_itemname(i);
1181
1182 117 return ret;
1183 }
1184
1185 bool reset_guys()
1186 {
1187 // The .dat file's guys definitions are always synchronised with defdata.cpp's - even the tile settings.
1188 init_guys(V_GUYS);
1189 return true;
1190 }
1191
1192 bool reset_wpns(bool validate, zquestheader *Header)
1193 {
1194 bool ret = true;
1195 if (get_app_id() == App::zquest)
1196 ret = init_section(Header, ID_WEAPONS, NULL, NULL, validate);
1197
1198 for(int32_t i=0; i<MAXWPNS; i++)
1199 reset_weaponname(i);
1200
1201 return ret;
1202 }
1203
1204 bool reset_mapstyles(bool validate, miscQdata *Misc)
1205 {
1206 Misc->colors.blueframe_tile = 20044;
1207 Misc->colors.blueframe_cset = 0;
1208 Misc->colors.triforce_tile = 23461;
1209 Misc->colors.triforce_cset = 1;
1210 Misc->colors.triframe_tile = 18752;
1211 Misc->colors.triframe_cset = 1;
1212 Misc->colors.overworld_map_tile = 16990;
1213 Misc->colors.overworld_map_cset = 2;
1214 Misc->colors.HCpieces_tile = 21160;
1215 Misc->colors.HCpieces_cset = 8;
1216 Misc->colors.dungeon_map_tile = 19651;
1217 Misc->colors.dungeon_map_cset = 8;
1218 return true;
1219 }
1220
1221 117 int32_t get_qst_buffers()
1222 {
1223 117 memrequested+=(sizeof(mapscr)*MAPSCRS);
1224 117 Z_message("Allocating map buffer (%s)... ", byte_conversion2(sizeof(mapscr)*MAPSCRS,memrequested,-1, -1));
1225 117 TheMaps.resize(MAPSCRS);
1226 117 map_autolayers.resize(6);
1227
1228
2/2
✓ Branch 0 taken 15912 times.
✓ Branch 1 taken 117 times.
16029 for(int32_t i(0); i<MAPSCRS; i++)
1229 15912 TheMaps[i].zero_memory();
1230
1231 //memset(TheMaps, 0, sizeof(mapscr)*MAPSCRS); //shouldn't need this anymore
1232 117 Z_message("OK\n");
1233
1234 // Allocating space for all 65535 strings uses up 10.62MB...
1235 // The vast majority of finished quests (and I presume this will be consistent for all time) use < 1000 strings in total.
1236 // (Shoelace's "Hero of Dreams" uses 1415.)
1237 // So let's be a bit generous and allow 4096 initially.
1238 // In the rare event that a quest overshoots this mark, we'll reallocate to the full 65535 later.
1239 // I tested it and it worked without flaw on 6/6/11. - L.
1240 // 2022: bumped from 4096 to 8192 to avoid a bug where the Strings menu shows (None) strings when the list passes
1241 // this threshold. Possibly some bug related to `msglistcache` to being reset?
1242 // See https://discord.com/channels/876899628556091432/992984989073416242
1243 117 msg_strings_size = 8192;
1244 117 memrequested+=(sizeof(MsgStr)*msg_strings_size);
1245 117 Z_message("Allocating string buffer (%s)... ", byte_conversion2(sizeof(MsgStr)*msg_strings_size,memrequested,-1,-1));
1246
1247
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 117 times.
117 MsgStrings = new MsgStr[msg_strings_size];
1248
1249 //memset(MsgStrings, 0, sizeof(MsgStr)*msg_strings_size);
1250
2/2
✓ Branch 0 taken 958464 times.
✓ Branch 1 taken 117 times.
958581 for(auto q = 0; q < msg_strings_size; ++q)
1251 {
1252 958464 MsgStrings[q].clear();
1253 958464 }
1254 117 Z_message("OK\n"); // Allocating string buffer...
1255
1256 117 memrequested+=(sizeof(DoorComboSet)*MAXDOORCOMBOSETS);
1257 117 Z_message("Allocating door combo buffer (%s)... ", byte_conversion2(sizeof(DoorComboSet)*MAXDOORCOMBOSETS,memrequested,-1,-1));
1258
1259
1/2
✓ Branch 0 taken 117 times.
✗ Branch 1 not taken.
117 if((DoorComboSets=(DoorComboSet*)malloc(sizeof(DoorComboSet)*MAXDOORCOMBOSETS))==NULL)
1260 return 0;
1261
1262 117 Z_message("OK\n"); // Allocating door combo buffer...
1263
1264 117 memrequested+=(sizeof(dmap)*MAXDMAPS);
1265 117 Z_message("Allocating dmap buffer (%s)... ", byte_conversion2(sizeof(dmap)*MAXDMAPS,memrequested,-1,-1));
1266
1267
1/2
✓ Branch 0 taken 117 times.
✗ Branch 1 not taken.
117 if((DMaps=new dmap[MAXDMAPS])==NULL)
1268 return 0;
1269
1270 117 Z_message("OK\n"); // Allocating dmap buffer...
1271
1272 117 memrequested+=(sizeof(newcombo)*MAXCOMBOS);
1273 117 Z_message("Allocating combo buffer (%s)... ", byte_conversion2(sizeof(newcombo)*MAXCOMBOS,memrequested,-1,-1));
1274
1275 117 combobuf.clear();
1276 117 combobuf.resize(MAXCOMBOS);
1277 117 Z_message("OK\n"); // Allocating combo buffer...
1278
1279 117 memrequested+=(psTOTAL255);
1280 117 Z_message("Allocating color data buffer (%s)... ", byte_conversion2(psTOTAL255,memrequested,-1,-1));
1281
1282
1/2
✓ Branch 0 taken 117 times.
✗ Branch 1 not taken.
117 if((colordata=(byte*)malloc(psTOTAL255))==NULL)
1283 return 0;
1284
1285 117 Z_message("OK\n"); // Allocating color data buffer...
1286
1287 117 memrequested+=(NEWMAXTILES*(sizeof(tiledata)+tilesize(tf4Bit)));
1288 117 Z_message("Allocating tile buffer (%s)... ", byte_conversion2(NEWMAXTILES*(sizeof(tiledata)+tilesize(tf4Bit)),memrequested,-1,-1));
1289
1290 117 free_newtilebuf();
1291
1/2
✓ Branch 0 taken 117 times.
✗ Branch 1 not taken.
117 if((newtilebuf=(tiledata*)malloc(NEWMAXTILES*sizeof(tiledata)))==NULL)
1292 return 0;
1293
1294 117 memset(newtilebuf, 0, NEWMAXTILES*sizeof(tiledata));
1295 //Z_message("Performed memset on tiles\n");
1296 117 clear_tiles(newtilebuf);
1297 //Z_message("Performed clear_tiles()\n");
1298 117 Z_message("OK\n"); // Allocating tile buffer...
1299
1300
1/2
✓ Branch 0 taken 117 times.
✗ Branch 1 not taken.
117 if(is_editor())
1301 {
1302 memrequested+=(NEWMAXTILES*(sizeof(tiledata)+tilesize(tf4Bit)));
1303 Z_message("Allocating tile grab buffer (%s)... ", byte_conversion2(NEWMAXTILES*sizeof(tiledata),memrequested,-1,-1));
1304
1305 if((grabtilebuf=(tiledata*)malloc(NEWMAXTILES*sizeof(tiledata)))==NULL)
1306 return 0;
1307
1308 memset(grabtilebuf, 0, NEWMAXTILES*sizeof(tiledata));
1309 clear_tiles(grabtilebuf);
1310 Z_message("OK\n"); // Allocating tile grab buffer...
1311 }
1312
1313 117 memrequested+=(100000);
1314 117 Z_message("Allocating trash buffer (%s)... ", byte_conversion2(100000,memrequested,-1,-1));
1315
1316
1/2
✓ Branch 0 taken 117 times.
✗ Branch 1 not taken.
117 if((trashbuf=(byte*)malloc(100000))==NULL)
1317 return 0;
1318
1319 117 Z_message("OK\n"); // Allocating trash buffer...
1320
1321 // Big, ugly band-aid here. Perhaps the most common cause of random crashes
1322 // has been inadvertently accessing itemsbuf[-1]. All such crashes should be
1323 // fixed by ensuring there's actually itemdata there.
1324 // If you change this, be sure to update del_qst_buffers, too.
1325
1326 117 memrequested+=(sizeof(itemdata)*(MAXITEMS+1));
1327 117 Z_message("Allocating item buffer (%s)... ", byte_conversion2(sizeof(itemdata)*(MAXITEMS+1),memrequested,-1,-1));
1328
1329
1/2
✓ Branch 0 taken 117 times.
✗ Branch 1 not taken.
117 if((itemsbuf=(itemdata*)malloc(sizeof(itemdata)*(MAXITEMS+1)))==NULL)
1330 return 0;
1331
1332 117 memset(itemsbuf,0,sizeof(itemdata)*(MAXITEMS+1));
1333 117 itemsbuf++;
1334 117 Z_message("OK\n"); // Allocating item buffer...
1335
1336 117 memrequested+=(sizeof(wpndata)*MAXWPNS);
1337 117 Z_message("Allocating weapon buffer (%s)... ", byte_conversion2(sizeof(wpndata)*MAXWPNS,memrequested,-1,-1));
1338
1339
1/2
✓ Branch 0 taken 117 times.
✗ Branch 1 not taken.
117 if((wpnsbuf=(wpndata*)malloc(sizeof(wpndata)*MAXWPNS))==NULL)
1340 return 0;
1341
1342 117 memset(wpnsbuf,0,sizeof(wpndata)*MAXWPNS);
1343 117 Z_message("OK\n"); // Allocating weapon buffer...
1344
1345 117 memrequested+=(sizeof(guydata)*MAXGUYS);
1346 117 Z_message("Allocating guy buffer (%s)... ", byte_conversion2(sizeof(guydata)*MAXGUYS,memrequested,-1,-1));
1347
1348
1/2
✓ Branch 0 taken 117 times.
✗ Branch 1 not taken.
117 if((guysbuf=(guydata*)malloc(sizeof(guydata)*MAXGUYS))==NULL)
1349 return 0;
1350
1351 117 memset(guysbuf,0,sizeof(guydata)*MAXGUYS);
1352 117 Z_message("OK\n"); // Allocating guy buffer...
1353
1354 117 memrequested+=(sizeof(comboclass)*cMAX);
1355 117 Z_message("Allocating combo class buffer (%s)... ", byte_conversion2(sizeof(comboclass)*cMAX,memrequested,-1,-1));
1356
1357
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 117 times.
117 if((combo_class_buf=(comboclass*)malloc(sizeof(comboclass)*cMAX))==NULL)
1358 return 0;
1359
1360 117 Z_message("OK\n"); // Allocating combo class buffer...
1361
1362 117 return 1;
1363 117 }
1364
1365
1366 117 void free_newtilebuf()
1367 {
1368
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 117 times.
117 if(newtilebuf)
1369 {
1370 for(int32_t i=0; i<NEWMAXTILES; i++)
1371 if(newtilebuf[i].data)
1372 free(newtilebuf[i].data);
1373
1374 free(newtilebuf);
1375 newtilebuf = 0;
1376 }
1377 117 }
1378
1379 void free_grabtilebuf()
1380 {
1381 if(is_editor())
1382 {
1383 if(grabtilebuf)
1384 {
1385 for(int32_t i=0; i<NEWMAXTILES; i++)
1386 if(grabtilebuf[i].data) free(grabtilebuf[i].data);
1387
1388 free(grabtilebuf);
1389 grabtilebuf = 0;
1390 }
1391 }
1392 }
1393
1394 void del_qst_buffers()
1395 {
1396 if(MsgStrings) delete[] MsgStrings;
1397
1398 if(DoorComboSets) free(DoorComboSets);
1399
1400 if (DMaps) delete[] DMaps;
1401
1402 combobuf.clear();
1403
1404 if(colordata) free(colordata);
1405
1406 free_newtilebuf();
1407 free_grabtilebuf();
1408
1409 if(trashbuf) free(trashbuf);
1410
1411 // See get_qst_buffers
1412 if(itemsbuf)
1413 {
1414 itemsbuf--;
1415 free(itemsbuf);
1416 }
1417
1418 if(wpnsbuf) free(wpnsbuf);
1419
1420 if(guysbuf) free(guysbuf);
1421
1422 if(combo_class_buf) free(combo_class_buf);
1423 }
1424
1425 4 bool init_palnames()
1426 {
1427 // if(palnames==NULL)
1428 // return false;
1429
1430
2/2
✓ Branch 0 taken 2048 times.
✓ Branch 1 taken 4 times.
2052 for(int32_t x=0; x<MAXLEVELS; x++)
1431 {
1432
4/4
✓ Branch 0 taken 2036 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 4 times.
2048 switch(x)
1433 {
1434 case 0:
1435 4 sprintf(palnames[x],"Overworld");
1436 4 break;
1437
1438 case 10:
1439 4 sprintf(palnames[x],"Caves");
1440 4 break;
1441
1442 case 11:
1443 4 sprintf(palnames[x],"Passageways");
1444 4 break;
1445
1446 default:
1447 2036 sprintf(palnames[x],"%c",0);
1448 2036 break;
1449 }
1450 2048 }
1451
1452 4 return true;
1453 }
1454
1455 25214 static void *read_block(PACKFILE *f, int32_t size, int32_t alloc_size)
1456 {
1457 void *p;
1458
1459
1/2
✓ Branch 0 taken 25214 times.
✗ Branch 1 not taken.
25214 p = _AL_MALLOC(MAX(size, alloc_size));
1460
1461
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25214 times.
25214 if(!p)
1462 {
1463 return NULL;
1464 }
1465
1466
1/2
✓ Branch 0 taken 25214 times.
✗ Branch 1 not taken.
25214 if(!pfread(p,size,f))
1467 {
1468 _AL_FREE(p);
1469 return NULL;
1470 }
1471
1472
1/2
✓ Branch 0 taken 25214 times.
✗ Branch 1 not taken.
25214 if(pack_ferror(f))
1473 {
1474 _AL_FREE(p);
1475 return NULL;
1476 }
1477
1478 25214 return p;
1479 25214 }
1480
1481 // Only use for reading parts of older quests (Header->zelda_version <= 0x192)
1482 static const byte* legacy_skip_flags;
1483
1484 /* read_midi:
1485 * Reads MIDI data from a datafile (this is not the same thing as the
1486 * standard midi file format).
1487 */
1488
1489 2304 static MIDI *read_midi(PACKFILE *f)
1490 {
1491 MIDI *m;
1492 int32_t c;
1493 2304 int16_t divisions=0;
1494 2304 int32_t len=0;
1495
1496 2304 m = (MIDI*)_AL_MALLOC(sizeof(MIDI));
1497
1498
1/2
✓ Branch 0 taken 2304 times.
✗ Branch 1 not taken.
2304 if(!m)
1499 {
1500 return NULL;
1501 }
1502
1503
2/2
✓ Branch 0 taken 73728 times.
✓ Branch 1 taken 2304 times.
76032 for(c=0; c<MIDI_TRACKS; c++)
1504 {
1505 73728 m->track[c].len = 0;
1506 73728 m->track[c].data = NULL;
1507 73728 }
1508
1509 2304 p_mgetw(&divisions,f);
1510 2304 m->divisions=divisions;
1511
1512
2/2
✓ Branch 0 taken 73728 times.
✓ Branch 1 taken 2304 times.
76032 for(c=0; c<MIDI_TRACKS; c++)
1513 {
1514 73728 p_mgetl(&len,f);
1515 73728 m->track[c].len=len;
1516
1517
2/2
✓ Branch 0 taken 48514 times.
✓ Branch 1 taken 25214 times.
73728 if(m->track[c].len > 0)
1518 {
1519 25214 m->track[c].data = (byte*)read_block(f, m->track[c].len, 0);
1520
1521
1/2
✓ Branch 0 taken 25214 times.
✗ Branch 1 not taken.
25214 if(!m->track[c].data)
1522 {
1523 destroy_midi(m);
1524 return NULL;
1525 }
1526 25214 }
1527 73728 }
1528
1529 LOCK_DATA(m, sizeof(MIDI));
1530
1531
2/2
✓ Branch 0 taken 73728 times.
✓ Branch 1 taken 2304 times.
76032 for(c=0; c<MIDI_TRACKS; c++)
1532 {
1533
2/2
✓ Branch 0 taken 25214 times.
✓ Branch 1 taken 48514 times.
73728 if(m->track[c].data)
1534 {
1535 LOCK_DATA(m->track[c].data, m->track[c].len);
1536 25214 }
1537 73728 }
1538
1539 2304 return m;
1540 2304 }
1541
1542 void clear_combo(int32_t i)
1543 {
1544 combobuf[i].clear();
1545 }
1546
1547 void clear_combos()
1548 {
1549 for(int32_t tmpcounter=0; tmpcounter<MAXCOMBOS; tmpcounter++)
1550 clear_combo(tmpcounter);
1551 }
1552
1553 void pack_combos()
1554 {
1555 int32_t di = 0;
1556
1557 for(int32_t si=0; si<1024; si+=2)
1558 combobuf[di++] = combobuf[si];
1559
1560 for(; di<1024; di++)
1561 clear_combo(di);
1562 }
1563
1564 131 void reset_tunes(zctune *tune)
1565 {
1566
2/2
✓ Branch 0 taken 33012 times.
✓ Branch 1 taken 131 times.
33143 for(int32_t i=0; i<MAXCUSTOMTUNES; i++)
1567 {
1568 33012 tune[i].reset();
1569 33012 }
1570 131 }
1571
1572
1573 /*void reset_midi(zcmidi_ *m)
1574 {
1575 m->title[0]=0;
1576 m->loop=1;
1577 m->volume=144;
1578 m->start=0;
1579 m->loop_start=-1;
1580 m->loop_end=-1;
1581 if(m->midi)
1582 {
1583 destroy_midi(m->midi);
1584 }
1585 m->midi=NULL;
1586 }
1587
1588
1589 void reset_midis(zcmidi_ *m)
1590 {
1591 for(int32_t i=0; i<MAXCUSTOMMIDIS; i++)
1592 {
1593 reset_midi(m+i);
1594 }
1595 }
1596 */
1597
1598 void reset_scr(int32_t scr)
1599 {
1600 /*
1601 byte *di=((byte*)TheMaps)+(scr*sizeof(mapscr));
1602 for(unsigned i=0; i<sizeof(mapscr); i++)
1603 *(di++) = 0;
1604 TheMaps[scr].valid=mVERSION;
1605 */
1606
1607 TheMaps[scr].zero_memory();
1608 //byte *di=((byte*)TheMaps)+(scr*sizeof(mapscr));
1609
1610 for(int32_t i=0; i<6; i++)
1611 {
1612 //these will be uncommented later
1613 //TheMaps[scr].layerxsize[i]=16;
1614 //TheMaps[scr].layerysize[i]=11;
1615 TheMaps[scr].layeropacity[i]=255;
1616 }
1617
1618 TheMaps[scr].valid=mVERSION;
1619
1620 }
1621
1622 /* For reference:
1623
1624 enum { qe_OK, qe_notfound, qe_invalid, qe_version, qe_obsolete,
1625 qe_missing, qe_internal, qe_pwd, qe_match, qe_minver };
1626 */
1627
1628 3574 int32_t operator ==(DoorComboSet a, DoorComboSet b)
1629 {
1630
2/2
✓ Branch 0 taken 16422 times.
✓ Branch 1 taken 1606 times.
18028 for(int32_t i=0; i<9; i++)
1631 {
1632
2/2
✓ Branch 0 taken 88692 times.
✓ Branch 1 taken 14454 times.
103146 for(int32_t j=0; j<6; j++)
1633 {
1634
2/2
✓ Branch 0 taken 28908 times.
✓ Branch 1 taken 59784 times.
88692 if(j<4)
1635 {
1636
2/2
✓ Branch 0 taken 57816 times.
✓ Branch 1 taken 1968 times.
59784 if(a.doorcombo_u[i][j]!=b.doorcombo_u[i][j])
1637 {
1638 1968 return false;
1639 }
1640
1641
1/2
✓ Branch 0 taken 57816 times.
✗ Branch 1 not taken.
57816 if(a.doorcset_u[i][j]!=b.doorcset_u[i][j])
1642 {
1643 return false;
1644 }
1645
1646
1/2
✓ Branch 0 taken 57816 times.
✗ Branch 1 not taken.
57816 if(a.doorcombo_d[i][j]!=b.doorcombo_d[i][j])
1647 {
1648 return false;
1649 }
1650
1651
1/2
✓ Branch 0 taken 57816 times.
✗ Branch 1 not taken.
57816 if(a.doorcset_d[i][j]!=b.doorcset_d[i][j])
1652 {
1653 return false;
1654 }
1655 57816 }
1656
1657
1/2
✓ Branch 0 taken 86724 times.
✗ Branch 1 not taken.
86724 if(a.doorcombo_l[i][j]!=b.doorcombo_l[i][j])
1658 {
1659 return false;
1660 }
1661
1662
1/2
✓ Branch 0 taken 86724 times.
✗ Branch 1 not taken.
86724 if(a.doorcset_l[i][j]!=b.doorcset_l[i][j])
1663 {
1664 return false;
1665 }
1666
1667
1/2
✓ Branch 0 taken 86724 times.
✗ Branch 1 not taken.
86724 if(a.doorcombo_r[i][j]!=b.doorcombo_r[i][j])
1668 {
1669 return false;
1670 }
1671
1672
1/2
✓ Branch 0 taken 86724 times.
✗ Branch 1 not taken.
86724 if(a.doorcset_r[i][j]!=b.doorcset_r[i][j])
1673 {
1674 return false;
1675 }
1676 86724 }
1677
1678
2/2
✓ Branch 0 taken 11242 times.
✓ Branch 1 taken 3212 times.
14454 if(i<2)
1679 {
1680
1/2
✓ Branch 0 taken 3212 times.
✗ Branch 1 not taken.
3212 if(a.flags[i]!=b.flags[i])
1681 {
1682 return false;
1683 }
1684
1685
1/2
✓ Branch 0 taken 3212 times.
✗ Branch 1 not taken.
3212 if(a.bombdoorcombo_u[i]!=b.bombdoorcombo_u[i])
1686 {
1687 return false;
1688 }
1689
1690
1/2
✓ Branch 0 taken 3212 times.
✗ Branch 1 not taken.
3212 if(a.bombdoorcset_u[i]!=b.bombdoorcset_u[i])
1691 {
1692 return false;
1693 }
1694
1695
1/2
✓ Branch 0 taken 3212 times.
✗ Branch 1 not taken.
3212 if(a.bombdoorcombo_d[i]!=b.bombdoorcombo_d[i])
1696 {
1697 return false;
1698 }
1699
1700
1/2
✓ Branch 0 taken 3212 times.
✗ Branch 1 not taken.
3212 if(a.bombdoorcset_d[i]!=b.bombdoorcset_d[i])
1701 {
1702 return false;
1703 }
1704 3212 }
1705
1706
2/2
✓ Branch 0 taken 9636 times.
✓ Branch 1 taken 4818 times.
14454 if(i<3)
1707 {
1708
1/2
✓ Branch 0 taken 4818 times.
✗ Branch 1 not taken.
4818 if(a.bombdoorcombo_l[i]!=b.bombdoorcombo_l[i])
1709 {
1710 return false;
1711 }
1712
1713
1/2
✓ Branch 0 taken 4818 times.
✗ Branch 1 not taken.
4818 if(a.bombdoorcset_l[i]!=b.bombdoorcset_l[i])
1714 {
1715 return false;
1716 }
1717
1718
1/2
✓ Branch 0 taken 4818 times.
✗ Branch 1 not taken.
4818 if(a.bombdoorcombo_r[i]!=b.bombdoorcombo_r[i])
1719 {
1720 return false;
1721 }
1722
1723
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4818 times.
4818 if(a.bombdoorcset_r[i]!=b.bombdoorcset_r[i])
1724 {
1725 return false;
1726 }
1727 4818 }
1728
1729
1/2
✓ Branch 0 taken 14454 times.
✗ Branch 1 not taken.
14454 if(a.walkthroughcombo[i]!=b.walkthroughcombo[i])
1730 {
1731 return false;
1732 }
1733
1734
1/2
✓ Branch 0 taken 14454 times.
✗ Branch 1 not taken.
14454 if(a.walkthroughcset[i]!=b.walkthroughcset[i])
1735 {
1736 return false;
1737 }
1738 14454 }
1739
1740 1606 return true;
1741 3574 }
1742
1743 int32_t doortranslations_u[9][4]=
1744 {
1745 {37,38,53,54},
1746 {37,38,39,40},
1747 {37,38,55,56},
1748 {37,38,39,40},
1749 {37,38,53,54},
1750 {37,38,53,54},
1751 {37,38,53,54},
1752 {7,8,23,24},
1753 {7,8,41,42}
1754 };
1755
1756 int32_t doortranslations_d[9][4]=
1757 {
1758 {117,118,133,134},
1759 {135,136,133,134},
1760 {119,120,133,134},
1761 {135,136,133,134},
1762 {117,118,133,134},
1763 {117,118,133,134},
1764 {117,118,133,134},
1765 {151,152,167,168},
1766 {137,138,167,168},
1767 };
1768
1769 //enum {dt_pass=0, dt_lock, dt_shut, dt_boss, dt_olck, dt_osht, dt_obos, dt_wall, dt_bomb, dt_walk, dt_max};
1770 int32_t doortranslations_l[9][6]=
1771 {
1772 {66,67,82,83,98,99},
1773 {66,68,82,84,98,100},
1774 {66,69,82,85,98,101},
1775 {66,68,82,84,98,100},
1776 {66,67,82,83,98,99},
1777 {66,67,82,83,98,99},
1778 {66,67,82,83,98,99},
1779 {64,65,80,81,96,97},
1780 {64,65,80,114,96,97},
1781 };
1782
1783 int32_t doortranslations_r[9][6]=
1784 {
1785
1786 {76,77,92,93,108,109},
1787 {75,77,91,93,107,109},
1788 {74,77,90,93,106,109},
1789 {75,77,91,93,107,109},
1790 {76,77,92,93,108,109},
1791 {76,77,92,93,108,109},
1792 {76,77,92,93,108,109},
1793 {78,79,94,95,110,111},
1794 {78,79,125,95,110,111},
1795 };
1796
1797 314668 int32_t tdcmbdat(int32_t map, int32_t scr, int32_t pos)
1798 {
1799 314668 return (TheMaps[map*MAPSCRS+TEMPLATE].data[pos]&0xFF)+((TheMaps[map*MAPSCRS+scr].old_cpage)<<8);
1800 }
1801
1802 308180 int32_t tdcmbcset(int32_t map, int32_t scr, int32_t pos)
1803 {
1804 //these are here to bypass compiler warnings about unused arguments
1805 308180 map=map;
1806 308180 scr=scr;
1807 308180 pos=pos;
1808
1809 //what does this function do?
1810 // return TheMaps[map*MAPSCRS+TEMPLATE].cset[pos];
1811 308180 return 2;
1812 }
1813
1814 7072 int32_t MakeDoors(int32_t map, int32_t scr)
1815 {
1816
2/2
✓ Branch 0 taken 5450 times.
✓ Branch 1 taken 1622 times.
7072 if(!(TheMaps[map*MAPSCRS+scr].valid&mVALID))
1817 {
1818 5450 return 0;
1819 }
1820
1821 DoorComboSet tempdcs;
1822 1622 memset(&tempdcs, 0, sizeof(DoorComboSet));
1823
1824 //up
1825
2/2
✓ Branch 0 taken 14598 times.
✓ Branch 1 taken 1622 times.
16220 for(int32_t i=0; i<9; i++)
1826 {
1827
2/2
✓ Branch 0 taken 58392 times.
✓ Branch 1 taken 14598 times.
72990 for(int32_t j=0; j<4; j++)
1828 {
1829 58392 tempdcs.doorcombo_u[i][j]=tdcmbdat(map,scr,doortranslations_u[i][j]);
1830 58392 tempdcs.doorcset_u[i][j]=tdcmbcset(map,scr,doortranslations_u[i][j]);
1831 58392 }
1832 14598 }
1833
1834 1622 tempdcs.bombdoorcombo_u[0]=tdcmbdat(map,scr,57);
1835 1622 tempdcs.bombdoorcset_u[0]=tdcmbcset(map,scr,57);
1836 1622 tempdcs.bombdoorcombo_u[1]=tdcmbdat(map,scr,58);
1837 1622 tempdcs.bombdoorcset_u[1]=tdcmbcset(map,scr,58);
1838 1622 tempdcs.walkthroughcombo[0]=tdcmbdat(map,scr,34);
1839 1622 tempdcs.walkthroughcset[0]=tdcmbdat(map,scr,34);
1840
1841 //down
1842
2/2
✓ Branch 0 taken 14598 times.
✓ Branch 1 taken 1622 times.
16220 for(int32_t i=0; i<9; i++)
1843 {
1844
2/2
✓ Branch 0 taken 58392 times.
✓ Branch 1 taken 14598 times.
72990 for(int32_t j=0; j<4; j++)
1845 {
1846 58392 tempdcs.doorcombo_d[i][j]=tdcmbdat(map,scr,doortranslations_d[i][j]);
1847 58392 tempdcs.doorcset_d[i][j]=tdcmbcset(map,scr,doortranslations_d[i][j]);
1848 58392 }
1849 14598 }
1850
1851 1622 tempdcs.bombdoorcombo_d[0]=tdcmbdat(map,scr,121);
1852
1853 1622 tempdcs.bombdoorcset_d[0]=tdcmbcset(map,scr,121);
1854 1622 tempdcs.bombdoorcombo_d[1]=tdcmbdat(map,scr,122);
1855 1622 tempdcs.bombdoorcset_d[1]=tdcmbcset(map,scr,122);
1856 1622 tempdcs.walkthroughcombo[1]=tdcmbdat(map,scr,34);
1857 1622 tempdcs.walkthroughcset[1]=tdcmbdat(map,scr,34);
1858
1859 //left
1860 // TheMaps[i*MAPSCRS+j].warpdmap=TheOldMap.warpdmap;
1861
2/2
✓ Branch 0 taken 14598 times.
✓ Branch 1 taken 1622 times.
16220 for(int32_t i=0; i<9; i++)
1862 {
1863
2/2
✓ Branch 0 taken 87588 times.
✓ Branch 1 taken 14598 times.
102186 for(int32_t j=0; j<6; j++)
1864 {
1865 87588 tempdcs.doorcombo_l[i][j]=tdcmbdat(map,scr,doortranslations_l[i][j]);
1866 87588 tempdcs.doorcset_l[i][j]=tdcmbcset(map,scr,doortranslations_l[i][j]);
1867 87588 }
1868 14598 }
1869
1870
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1622 times.
1622 for(int32_t j=0; j>6; j++)
1871 {
1872 if((j!=2)&&(j!=3))
1873 {
1874 tempdcs.doorcombo_l[dt_bomb][j]=TheMaps[map*MAPSCRS+scr].data[doortranslations_l[dt_bomb][j]];
1875 tempdcs.doorcset_l[dt_bomb][j]=TheMaps[map*MAPSCRS+scr].cset[doortranslations_l[dt_bomb][j]];
1876 }
1877 }
1878
1879 1622 tempdcs.bombdoorcombo_l[0]=0;
1880 1622 tempdcs.bombdoorcset_l[0]=tdcmbcset(map,scr,115);
1881 1622 tempdcs.bombdoorcombo_l[1]=tdcmbdat(map,scr,115);
1882 1622 tempdcs.bombdoorcset_l[1]=tdcmbcset(map,scr,115);
1883 1622 tempdcs.bombdoorcombo_l[2]=0;
1884 1622 tempdcs.bombdoorcset_l[2]=tdcmbcset(map,scr,115);
1885 1622 tempdcs.walkthroughcombo[2]=tdcmbdat(map,scr,34);
1886 1622 tempdcs.walkthroughcset[2]=tdcmbdat(map,scr,34);
1887
1888 //right
1889
2/2
✓ Branch 0 taken 14598 times.
✓ Branch 1 taken 1622 times.
16220 for(int32_t i=0; i<9; i++)
1890 {
1891
2/2
✓ Branch 0 taken 87588 times.
✓ Branch 1 taken 14598 times.
102186 for(int32_t j=0; j<6; j++)
1892 {
1893 87588 tempdcs.doorcombo_r[i][j]=tdcmbdat(map,scr,doortranslations_r[i][j]);
1894 87588 tempdcs.doorcset_r[i][j]=tdcmbcset(map,scr,doortranslations_r[i][j]);
1895 87588 }
1896 14598 }
1897
1898
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1622 times.
1622 for(int32_t j=0; j>6; j++)
1899 {
1900 if((j!=2)&&(j!=3))
1901 {
1902 tempdcs.doorcombo_r[dt_bomb][j]=TheMaps[map*MAPSCRS+scr].data[doortranslations_r[dt_bomb][j]];
1903 tempdcs.doorcset_r[dt_bomb][j]=TheMaps[map*MAPSCRS+scr].cset[doortranslations_r[dt_bomb][j]];
1904 }
1905 }
1906
1907 1622 tempdcs.bombdoorcombo_r[0]=0;
1908 1622 tempdcs.bombdoorcset_r[0]=tdcmbcset(map,scr,124);
1909 1622 tempdcs.bombdoorcombo_r[1]=tdcmbdat(map,scr,124);
1910 1622 tempdcs.bombdoorcset_r[1]=tdcmbcset(map,scr,124);
1911 1622 tempdcs.bombdoorcombo_r[2]=0;
1912 1622 tempdcs.bombdoorcset_r[2]=tdcmbcset(map,scr,124);
1913 1622 tempdcs.walkthroughcombo[3]=tdcmbdat(map,scr,34);
1914 1622 tempdcs.walkthroughcset[3]=tdcmbdat(map,scr,34);
1915
1916 int32_t k;
1917
1918
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 3574 times.
3590 for(k=0; k<door_combo_set_count; k++)
1919 {
1920
2/2
✓ Branch 0 taken 1606 times.
✓ Branch 1 taken 1968 times.
3574 if(DoorComboSets[k]==tempdcs)
1921 {
1922 1606 break;
1923 }
1924 1968 }
1925
1926
2/2
✓ Branch 0 taken 1606 times.
✓ Branch 1 taken 16 times.
1622 if(k==door_combo_set_count)
1927 {
1928 16 DoorComboSets[k]=tempdcs;
1929 16 sprintf(DoorComboSets[k].name, "Door Combo Set %d", k);
1930 16 ++door_combo_set_count;
1931 16 }
1932
1933 1622 return k;
1934 /*
1935 doorcombo_u[9][4];
1936 doorcset_u[9][4];
1937 doorcombo_d[9][4];
1938 doorcset_d[9][4];
1939 doorcombo_l[9][6];
1940 doorcset_l[9][6];
1941 doorcombo_r[9][6];
1942 doorcset_r[9][6];
1943 bombdoorcombo_u[2];
1944 bombdoorcset_u[2];
1945 bombdoorcombo_d[2];
1946 bombdoorcset_d[2];
1947 bombdoorcombo_l[3];
1948 bombdoorcset_l[3];
1949 bombdoorcombo_r[3];
1950 bombdoorcset_r[3];
1951 walkthroughcombo[4];
1952 walkthroughcset[4];
1953 */
1954 7072 }
1955
1956 905216 INLINE int32_t tcmbdat2(int32_t map, int32_t scr, int32_t pos)
1957 {
1958 905216 return (TheMaps[map*MAPSCRS+TEMPLATE2].data[pos]&0xFF)+((TheMaps[map*MAPSCRS+scr].old_cpage)<<8);
1959 }
1960
1961 905216 INLINE int32_t tcmbcset2(int32_t map, int32_t pos)
1962 {
1963
1964 905216 return TheMaps[map*MAPSCRS+TEMPLATE2].cset[pos];
1965 }
1966
1967 905216 INLINE int32_t tcmbflag2(int32_t map, int32_t pos)
1968 {
1969 905216 return TheMaps[map*MAPSCRS+TEMPLATE2].sflag[pos];
1970 }
1971
1972
1973 16 void get_questpwd(char *encrypted_pwd, int16_t pwdkey, char *pwd)
1974 {
1975 char temp_pwd[30];
1976 16 memset(temp_pwd,0,30);
1977
1978
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(pwdkey!=0)
1979 {
1980 16 memcpy(temp_pwd,encrypted_pwd,30);
1981 16 temp_pwd[29]=0;
1982
1983
2/2
✓ Branch 0 taken 480 times.
✓ Branch 1 taken 16 times.
496 for(int32_t i=0; i<30; i++)
1984 {
1985 480 temp_pwd[i] -= pwdkey;
1986 480 int32_t t=pwdkey>>15;
1987 480 pwdkey = (pwdkey<<1)+t;
1988 480 }
1989 16 }
1990
1991 16 memcpy(pwd,temp_pwd,30);
1992 16 }
1993
1994
1995 92 bool devpwd()
1996 {
1997 #ifdef _DEBUG
1998 return true;
1999 #endif
2000
1/2
✓ Branch 0 taken 92 times.
✗ Branch 1 not taken.
92 return !strcmp(zc_get_config("dev","pwd","",App::zquest), (char*)clavio) || is_ci();
2001 }
2002 bool check_questpwd(zquestheader *Header, char *pwd)
2003 {
2004 #if DEVLEVEL > 3
2005 return true;
2006 #endif
2007
2008 if (devpwd()) return true;
2009 if ( (!strcmp(pwd, (char*)clavio)) ) return true;
2010 cvs_MD5Context ctx;
2011 uint8_t md5sum[16];
2012
2013 cvs_MD5Init(&ctx);
2014 cvs_MD5Update(&ctx, (const uint8_t*)pwd, (unsigned)strlen(pwd));
2015 cvs_MD5Final(md5sum, &ctx);
2016
2017 return (memcmp(Header->pwd_hash,md5sum,16)==0);
2018 }
2019
2020 123 void print_quest_metadata(zquestheader const& tempheader, char const* path, byte qst_num)
2021 {
2022 123 zprint2("\n");
2023 123 zprint2("[QUEST METADATA]\n");
2024
1/2
✓ Branch 0 taken 123 times.
✗ Branch 1 not taken.
123 if(qst_num < moduledata.max_quest_files)
2025 zprint2("Loading module quest %d\n", qst_num+1);
2026
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 123 times.
123 if(path) zprint2("Loading '%s'\n", path);
2027
2/2
✓ Branch 0 taken 119 times.
✓ Branch 1 taken 4 times.
123 if ( tempheader.new_version_id_main > 0 )
2028 {
2029
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 119 times.
119 if(tempheader.new_version_id_fourth > 0)
2030 zprint2("Last saved in version %d.%d.%d.%d ",
2031 tempheader.new_version_id_main,tempheader.new_version_id_second,
2032 tempheader.new_version_id_third,tempheader.new_version_id_fourth);
2033 119 else zprint2("Last saved in version: %d.%d.%d ",
2034 119 tempheader.new_version_id_main,tempheader.new_version_id_second,
2035 119 tempheader.new_version_id_third);
2036 119 }
2037 else
2038 {
2039
1/6
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 4 times.
✗ Branch 5 not taken.
4 switch ( tempheader.zelda_version )
2040 {
2041 case 0x255:
2042 {
2043 zprint2("Last saved in version: 2.55.0, %s: %d", tempheader.getAlphaStr(), tempheader.getAlphaVer());
2044 break;
2045 }
2046 case 0x254:
2047 {
2048 zprint2("Last saved in version: 2.54.0, Alpha Build ID: %d", tempheader.build);
2049 break;
2050 }
2051 case 0x250:
2052 {
2053 switch(tempheader.build)
2054 {
2055 case 19:
2056 zprint2("Last saved in version: 2.50.0, Gamma 1"); break;
2057 case 20:
2058 zprint2("Last saved in version: 2.50.0, Gamma 2"); break;
2059 case 21:
2060 zprint2("Last saved in version: 2.50.0, Gamma 3"); break;
2061 case 22:
2062 zprint2("Last saved in version: 2.50.0, Gamma 4"); break;
2063 case 23:
2064 zprint2("Last saved in version: 2.50.0, Gamma 5"); break;
2065 case 24:
2066 zprint2("Last saved in version: 2.50.0, Release"); break;
2067 case 25:
2068 zprint2("Last saved in version: 2.50.1, Gamma 1"); break;
2069 case 26:
2070 zprint2("Last saved in version: 2.50.1, Gamma 2"); break;
2071 case 27:
2072 zprint2("Last saved in version: 2.50.1, Gamma 3"); break;
2073 case 28:
2074 zprint2("Last saved in version: 2.50.1, Release"); break;
2075 case 29:
2076 zprint2("Last saved in version: 2.50.2, Release"); break;
2077 case 30:
2078 zprint2("Last saved in version: 2.50.3, Gamma 1"); break;
2079 case 31:
2080 zprint2("Last saved in version: 2.53.0, Prior to Gamma 3"); break;
2081 case 32:
2082 zprint2("Last saved in version: 2.53.0"); break;
2083 case 33:
2084 zprint2("Last saved in version: 2.53.1"); break;
2085 default:
2086 zprint2("Last saved in version: %x, Build %d", tempheader.zelda_version,tempheader.build); break;
2087
2088 }
2089 break;
2090 }
2091
2092 case 0x211:
2093 {
2094 zprint2("Last saved in version: 2.11, Beta %d", tempheader.build); break;
2095 }
2096 case 0x210:
2097 {
2098 zprint2("Last saved in version: 2.10.x");
2099 if ( tempheader.build ) zprint2("Beta/Build %d\n", tempheader.build);
2100 break;
2101 }
2102 /* These versions cannot be handled here; they will be incorrect at this time. -Z
2103 case 0x193:
2104 {
2105 zprint2("Last saved in version: 1.93, Beta %d\n", tempheader.build); break;
2106 }
2107 case 0x192:
2108 {
2109 zprint2("Last saved in version: 1.92, Beta %d\n", tempheader.build); break;
2110 }
2111 case 0x190:
2112 {
2113 zprint2("Last saved in version: 1.90, Beta/Build %d\n", tempheader.build); break;
2114 }
2115 case 0x184:
2116 {
2117 zprint2("Last saved in version: 1.84, Beta/Build %d\n", tempheader.build); break;
2118 }
2119 case 0x183:
2120 {
2121 zprint2("Last saved in version: 1.83, Beta/Build %d\n", tempheader.build); break;
2122 }
2123 case 0x180:
2124 {
2125 zprint2("Last saved in version: 1.80, Beta/Build %d\n", tempheader.build); break;
2126 }
2127 default:
2128 {
2129 zprint2("Last saved in version: %x, Beta %d\n", tempheader.zelda_version,tempheader.build); break;
2130 }
2131 */
2132 }
2133 }
2134
3/4
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 93 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 30 times.
123 if(!tempheader.is_legacy() && tempheader.getAlphaVer())
2135 30 zprint2("%s\n", tempheader.getAlphaVerStr());
2136 93 else zprint2("\n");
2137
2/2
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 30 times.
123 if ( tempheader.made_in_module_name[0] ) zprint2("Created with ZC Module: %s\n\n", tempheader.made_in_module_name);
2138
2/2
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 30 times.
123 if ( tempheader.new_version_devsig[0] ) zprint2("Developr Signoff by: %s\n", tempheader.new_version_devsig);
2139
2/2
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 30 times.
123 if ( tempheader.new_version_compilername[0] ) zprint2("Compiled with: %s, (ID: %d)\n", tempheader.new_version_compilername, tempheader.compilerid);
2140
2/2
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 30 times.
123 if ( tempheader.new_version_compilerversion[0] ) zprint2("Compiler Version: %s, (%d,%d,%d,%d)\n", tempheader.new_version_compilerversion,tempheader.compilerversionnumber_first,tempheader.compilerversionnumber_second,tempheader.compilerversionnumber_third,tempheader.compilerversionnumber_fourth);
2141
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 119 times.
123 if ( tempheader.product_name[0] ) zprint2("Project ID: %s\n", tempheader.product_name);
2142
2/2
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 30 times.
123 if ( tempheader.new_version_id_date_day ) zprint2("Editor Built at date and time: %d-%d-%d at @ %s %s\n", tempheader.new_version_id_date_day, tempheader.new_version_id_date_month, tempheader.new_version_id_date_year, tempheader.build_timestamp, tempheader.build_timezone);
2143 123 zprint2("\n");
2144 123 }
2145
2146 131 int32_t readheader(PACKFILE *f, zquestheader *Header, byte printmetadata)
2147 {
2148 int32_t dummy;
2149 zquestheader tempheader;
2150 char dummybuf[80];
2151 byte temp_map_count;
2152 byte temp_midi_flags[MIDIFLAGS_SIZE];
2153 word version;
2154 char temp_pwd[30], temp_pwd2[30];
2155 int16_t temp_pwdkey;
2156 cvs_MD5Context ctx;
2157 131 memset(temp_midi_flags, 0, MIDIFLAGS_SIZE);
2158 131 memset(&tempheader, 0, sizeof(tempheader));
2159 131 memset(FFCore.quest_format, 0, sizeof(FFCore.quest_format));
2160
2161
2162
2163
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 131 times.
131 if(!pfread(tempheader.id_str,sizeof(tempheader.id_str),f)) // first read old header
2164 {
2165 Z_message("Unable to read header string\n");
2166 return qe_invalid;
2167 }
2168
2169 // check header
2170
2/2
✓ Branch 0 taken 127 times.
✓ Branch 1 taken 4 times.
131 if(strcmp(tempheader.id_str,QH_NEWIDSTR))
2171 {
2172
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(strcmp(tempheader.id_str,QH_IDSTR))
2173 {
2174 Z_message("Invalid header string: '%s' (was expecting '%s' or '%s')\n", tempheader.id_str, QH_IDSTR, QH_NEWIDSTR);
2175 return qe_invalid;
2176 }
2177 4 }
2178
2179 131 int32_t templatepath_len=0;
2180
2181 131 tempheader.external_zinfo = false;
2182 131 read_zinfo = false;
2183
2/2
✓ Branch 0 taken 127 times.
✓ Branch 1 taken 4 times.
131 if(!strcmp(tempheader.id_str,QH_IDSTR)) //pre-1.93 version
2184 {
2185 byte padding;
2186
2187
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&padding,f))
2188 {
2189 return qe_invalid;
2190 }
2191
2192
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_igetw(&tempheader.zelda_version,f))
2193 {
2194 return qe_invalid;
2195 }
2196
2197 4 FFCore.quest_format[vZelda] = tempheader.zelda_version;
2198
2199
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(tempheader.zelda_version > ZELDA_VERSION)
2200 {
2201 return qe_version;
2202 }
2203
2204 4 FFCore.quest_format[vZelda] = tempheader.zelda_version;
2205
2206
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(strcmp(tempheader.id_str,QH_IDSTR))
2207 {
2208 return qe_invalid;
2209 }
2210
2211
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(bad_version(tempheader.zelda_version))
2212 {
2213 return qe_obsolete;
2214 }
2215
2216
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_igetw(&tempheader.internal,f))
2217 {
2218 return qe_invalid;
2219 }
2220
2221
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&tempheader.quest_number,f))
2222 {
2223 return qe_invalid;
2224 }
2225
2226 4 FFCore.quest_format[qQuestNumber] = tempheader.quest_number;
2227
2228
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!pfread(&quest_rules[0],2,f))
2229 {
2230 return qe_invalid;
2231 }
2232
2233
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&temp_map_count,f))
2234 {
2235 return qe_invalid;
2236 }
2237
2238 4 FFCore.quest_format[qMapCount] = temp_map_count;
2239
2240
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&tempheader.old_str_count,f))
2241 {
2242 return qe_invalid;
2243 }
2244
2245
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&tempheader.data_flags[ZQ_TILES],f))
2246 {
2247 return qe_invalid;
2248 }
2249
2250
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!pfread(temp_midi_flags,4,f))
2251 {
2252 return qe_invalid;
2253 }
2254
2255
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&tempheader.data_flags[ZQ_CHEATS2],f))
2256 {
2257 return qe_invalid;
2258 }
2259
2260
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!pfread(dummybuf,14,f))
2261 {
2262 return qe_invalid;
2263 }
2264
2265
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!pfread(&quest_rules[2],2,f))
2266 {
2267 return qe_invalid;
2268 }
2269
2270
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&dummybuf,f))
2271 {
2272 return qe_invalid;
2273 }
2274
2275
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!pfread(tempheader.version,9,f))
2276 {
2277 return qe_invalid;
2278 }
2279
2280
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!pfread(tempheader.title,sizeof(tempheader.title),f))
2281 {
2282 return qe_invalid;
2283 }
2284 // These fields are expected to end in null bytes!
2285 4 tempheader.title[sizeof(tempheader.title)-1] = 0;
2286
2287
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!pfread(tempheader.author,sizeof(tempheader.author),f))
2288 {
2289 return qe_invalid;
2290 }
2291 4 tempheader.author[sizeof(tempheader.author)-1] = 0;
2292
2293
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&padding,f))
2294 {
2295 return qe_invalid;
2296 }
2297
2298
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_igetw(&temp_pwdkey,f))
2299 {
2300 return qe_invalid;
2301 }
2302
2303
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!pfread(temp_pwd,30,f))
2304 {
2305 return qe_invalid;
2306 }
2307
2308 4 get_questpwd(temp_pwd, temp_pwdkey, temp_pwd2);
2309 4 cvs_MD5Init(&ctx);
2310 4 cvs_MD5Update(&ctx, (const uint8_t*)temp_pwd2, (unsigned)strnlen(temp_pwd2, 30));
2311 4 cvs_MD5Final(tempheader.pwd_hash, &ctx);
2312
2313
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(tempheader.zelda_version < 0x177) // lacks new header stuff...
2314 {
2315 //memset(tempheader.minver,0,20); // char minver[9], byte build, byte foo[10]
2316 // Not anymore...
2317 memset(tempheader.minver,0,17);
2318 tempheader.build=0;
2319 tempheader.use_keyfile=0;
2320 memset(tempheader.old_foo, 0, 9);
2321 }
2322 else
2323 {
2324
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!pfread(tempheader.minver,9,f))
2325 {
2326 return qe_invalid;
2327 }
2328
2329
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&tempheader.build,f))
2330 {
2331 return qe_invalid;
2332 }
2333
2334 4 FFCore.quest_format[vBuild] = tempheader.build;
2335
2336
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&tempheader.use_keyfile,f))
2337 {
2338 return qe_invalid;
2339 }
2340
2341
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!pfread(dummybuf,9,f))
2342 {
2343 return qe_invalid;
2344 }
2345 } // starting at minver
2346
2347
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(tempheader.zelda_version < 0x187) // lacks newer header stuff...
2348 {
2349 memset(&quest_rules[4],0,16); // word rules3..rules10
2350 }
2351 else
2352 {
2353
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!pfread(&quest_rules[4],16,f)) // read new header additions
2354 {
2355 return qe_invalid; // starting at rules3
2356 }
2357
2358
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(tempheader.zelda_version <= 0x190)
2359 {
2360 4 set_qr(qr_MEANPLACEDTRAPS,0);
2361 4 }
2362 }
2363 4 unpack_qrs();
2364
2365
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4 if((tempheader.zelda_version < 0x192)||
2366 ((tempheader.zelda_version == 0x192)&&(tempheader.build<149)))
2367 {
2368 4 set_qr(qr_BRKNSHLDTILES,(get_qr(qr_BRKBLSHLDS_DEP)));
2369 4 set_bit(deprecated_rules,qr_BRKBLSHLDS_DEP,1);
2370 4 set_qr(qr_BRKBLSHLDS_DEP,1);
2371 4 }
2372
2373
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(tempheader.zelda_version >= 0x192) // lacks newer header stuff...
2374 {
2375 byte *mf=temp_midi_flags;
2376
2377 if((tempheader.zelda_version == 0x192)&&(tempheader.build<178))
2378 {
2379 mf=(byte*)dummybuf;
2380 }
2381
2382 if(!pfread(mf,32,f)) // read new header additions
2383 {
2384 return qe_invalid; // starting at foo2
2385 }
2386
2387 if(!pfread(dummybuf,18,f)) // read new header additions
2388 {
2389 return qe_invalid; // starting at foo2
2390 }
2391 }
2392
2393
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4 if((tempheader.zelda_version < 0x192)||
2394 ((tempheader.zelda_version == 0x192)&&(tempheader.build<145)))
2395 {
2396 4 memset(tempheader.templatepath,0,2048);
2397 4 }
2398 else
2399 {
2400 if(!pfread(tempheader.templatepath,280,f)) // read templatepath
2401 {
2402 return qe_invalid;
2403 }
2404 }
2405
2406
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4 if((tempheader.zelda_version < 0x192)||
2407 ((tempheader.zelda_version == 0x192)&&(tempheader.build<186)))
2408 {
2409 4 tempheader.use_keyfile=0;
2410 4 }
2411 4 }
2412 else
2413 {
2414 //section id
2415
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 127 times.
127 if(!p_mgetl(&dummy,f))
2416 {
2417 return qe_invalid;
2418 }
2419
2420 //section version info
2421
1/2
✓ Branch 0 taken 127 times.
✗ Branch 1 not taken.
127 if(!p_igetw(&version,f))
2422 {
2423 return qe_invalid;
2424 }
2425
2426 127 FFCore.quest_format[vHeader] = version;
2427
2428
1/2
✓ Branch 0 taken 127 times.
✗ Branch 1 not taken.
127 if(!p_igetw(&dummy,f))
2429 {
2430 return qe_invalid;
2431 }
2432
2433 //section size
2434
1/2
✓ Branch 0 taken 127 times.
✗ Branch 1 not taken.
127 if(!p_igetl(&dummy,f))
2435 {
2436 return qe_invalid;
2437 }
2438
2439 //finally... section data
2440
1/2
✓ Branch 0 taken 127 times.
✗ Branch 1 not taken.
127 if(!p_igetw(&tempheader.zelda_version,f))
2441 {
2442 return qe_invalid;
2443 }
2444
2445 127 FFCore.quest_format[vZelda] = tempheader.zelda_version;
2446
2447 //do some quick checking...
2448
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 127 times.
127 if(tempheader.zelda_version > ZELDA_VERSION)
2449 {
2450 return qe_version;
2451 }
2452
2453
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 127 times.
127 if(strcmp(tempheader.id_str,QH_NEWIDSTR))
2454 {
2455 return qe_invalid;
2456 }
2457
2458
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 127 times.
127 if(bad_version(tempheader.zelda_version))
2459 {
2460 return qe_obsolete;
2461 }
2462
2463
1/2
✓ Branch 0 taken 127 times.
✗ Branch 1 not taken.
127 if(!p_getc(&tempheader.build,f))
2464 {
2465 return qe_invalid;
2466 }
2467
2468 127 FFCore.quest_format[vBuild] = tempheader.build;
2469
2470
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 115 times.
127 if(version<3)
2471 {
2472
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!pfread(temp_pwd,30,f))
2473 {
2474 return qe_invalid;
2475 }
2476
2477
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_igetw(&temp_pwdkey,f))
2478 {
2479 return qe_invalid;
2480 }
2481
2482 12 get_questpwd(temp_pwd, temp_pwdkey, temp_pwd2);
2483 12 cvs_MD5Init(&ctx);
2484 12 cvs_MD5Update(&ctx, (const uint8_t*)temp_pwd2, (unsigned)strnlen(temp_pwd2, 30));
2485 12 cvs_MD5Final(tempheader.pwd_hash, &ctx);
2486 12 }
2487 else
2488 {
2489
1/2
✓ Branch 0 taken 115 times.
✗ Branch 1 not taken.
115 if(!pfread(tempheader.pwd_hash,sizeof(tempheader.pwd_hash),f))
2490 {
2491 return qe_invalid;
2492 }
2493 }
2494
2495
1/2
✓ Branch 0 taken 127 times.
✗ Branch 1 not taken.
127 if(!p_igetw(&tempheader.internal,f))
2496 {
2497 return qe_invalid;
2498 }
2499
2500
1/2
✓ Branch 0 taken 127 times.
✗ Branch 1 not taken.
127 if(!p_getc(&tempheader.quest_number,f))
2501 {
2502 return qe_invalid;
2503 }
2504
2505 127 FFCore.quest_format[qQuestNumber] = tempheader.quest_number;
2506
2507 127 size_t versz = version < 8 ? 9 : 16;
2508
1/2
✓ Branch 0 taken 127 times.
✗ Branch 1 not taken.
127 if(!pfread(tempheader.version,versz,f))
2509 {
2510 return qe_invalid;
2511 }
2512
2513 //FFCore.quest_format[qQuestVersion] = tempheader.version;
2514 //needs to be copied as char[9] or stored as a s.str
2515
1/2
✓ Branch 0 taken 127 times.
✗ Branch 1 not taken.
127 if(!pfread(tempheader.minver,versz,f))
2516 {
2517 return qe_invalid;
2518 }
2519
2520 //FFCore.quest_format[qMinQuestVersion] = tempheader.minver;
2521
1/2
✓ Branch 0 taken 127 times.
✗ Branch 1 not taken.
127 if(!pfread(tempheader.title,sizeof(tempheader.title),f))
2522 {
2523 return qe_invalid;
2524 }
2525 127 tempheader.title[sizeof(tempheader.title)-1] = 0;
2526
2527
1/2
✓ Branch 0 taken 127 times.
✗ Branch 1 not taken.
127 if(!pfread(tempheader.author,sizeof(tempheader.author),f))
2528 {
2529 return qe_invalid;
2530 }
2531 127 tempheader.author[sizeof(tempheader.author)-1] = 0;
2532
2533
1/2
✓ Branch 0 taken 127 times.
✗ Branch 1 not taken.
127 if(!p_getc(&tempheader.use_keyfile,f))
2534 {
2535 return qe_invalid;
2536 }
2537
2538 /*
2539 if(!pfread(tempheader.data_flags,sizeof(tempheader.data_flags),f))
2540 {
2541 return qe_invalid;
2542 }
2543 */
2544
1/2
✓ Branch 0 taken 127 times.
✗ Branch 1 not taken.
127 if(!p_getc(&tempheader.data_flags[ZQ_TILES],f))
2545 {
2546 return qe_invalid;
2547 }
2548
2549
1/2
✓ Branch 0 taken 127 times.
✗ Branch 1 not taken.
127 if(!pfread(&dummybuf,4,f))
2550 {
2551 return qe_invalid;
2552 }
2553
2554
1/2
✓ Branch 0 taken 127 times.
✗ Branch 1 not taken.
127 if(!p_getc(&tempheader.data_flags[ZQ_CHEATS2],f))
2555 {
2556 return qe_invalid;
2557 }
2558
2559
1/2
✓ Branch 0 taken 127 times.
✗ Branch 1 not taken.
127 if(!pfread(dummybuf,14,f))
2560 {
2561 return qe_invalid;
2562 }
2563
2564 127 templatepath_len=sizeof(tempheader.templatepath);
2565
2566
2/2
✓ Branch 0 taken 115 times.
✓ Branch 1 taken 12 times.
127 if(version==1)
2567 {
2568 12 templatepath_len=280;
2569 12 }
2570
2571
1/2
✓ Branch 0 taken 127 times.
✗ Branch 1 not taken.
127 if(!pfread(tempheader.templatepath,templatepath_len,f))
2572 {
2573 return qe_invalid;
2574 }
2575
2576
1/2
✓ Branch 0 taken 127 times.
✗ Branch 1 not taken.
127 if(!p_getc(&temp_map_count,f))
2577 {
2578 return qe_invalid;
2579 }
2580
2581
2/2
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 89 times.
127 if(version>=4)
2582 {
2583
1/2
✓ Branch 0 taken 38 times.
✗ Branch 1 not taken.
38 if(!p_igetl(&tempheader.new_version_id_main,f))
2584 {
2585 return qe_invalid;
2586 }
2587
1/2
✓ Branch 0 taken 38 times.
✗ Branch 1 not taken.
38 if(!p_igetl(&tempheader.new_version_id_second,f))
2588 {
2589 return qe_invalid;
2590 }
2591
1/2
✓ Branch 0 taken 38 times.
✗ Branch 1 not taken.
38 if(!p_igetl(&tempheader.new_version_id_third,f))
2592 {
2593 return qe_invalid;
2594 }
2595
1/2
✓ Branch 0 taken 38 times.
✗ Branch 1 not taken.
38 if(!p_igetl(&tempheader.new_version_id_fourth,f))
2596 {
2597 return qe_invalid;
2598 }
2599
1/2
✓ Branch 0 taken 38 times.
✗ Branch 1 not taken.
38 if(!p_igetl(&tempheader.new_version_id_alpha,f))
2600 {
2601 return qe_invalid;
2602 }
2603
1/2
✓ Branch 0 taken 38 times.
✗ Branch 1 not taken.
38 if(!p_igetl(&tempheader.new_version_id_beta,f))
2604 {
2605 return qe_invalid;
2606 }
2607
1/2
✓ Branch 0 taken 38 times.
✗ Branch 1 not taken.
38 if(!p_igetl(&tempheader.new_version_id_gamma,f))
2608 {
2609 return qe_invalid;
2610 }
2611
1/2
✓ Branch 0 taken 38 times.
✗ Branch 1 not taken.
38 if(!p_igetl(&tempheader.new_version_id_release,f))
2612 {
2613 return qe_invalid;
2614 }
2615
1/2
✓ Branch 0 taken 38 times.
✗ Branch 1 not taken.
38 if(!p_igetw(&tempheader.new_version_id_date_year,f))
2616 {
2617 return qe_invalid;
2618 }
2619
1/2
✓ Branch 0 taken 38 times.
✗ Branch 1 not taken.
38 if(!p_getc(&tempheader.new_version_id_date_month,f))
2620 {
2621 return qe_invalid;
2622 }
2623
1/2
✓ Branch 0 taken 38 times.
✗ Branch 1 not taken.
38 if(!p_getc(&tempheader.new_version_id_date_day,f))
2624 {
2625 return qe_invalid;
2626 }
2627
1/2
✓ Branch 0 taken 38 times.
✗ Branch 1 not taken.
38 if(!p_getc(&tempheader.new_version_id_date_hour,f))
2628 {
2629 return qe_invalid;
2630 }
2631
1/2
✓ Branch 0 taken 38 times.
✗ Branch 1 not taken.
38 if(!p_getc(&tempheader.new_version_id_date_minute,f))
2632 {
2633 return qe_invalid;
2634 }
2635
2636
1/2
✓ Branch 0 taken 38 times.
✗ Branch 1 not taken.
38 if(!pfread(tempheader.new_version_devsig,256,f))
2637 {
2638 return qe_invalid;
2639 }
2640
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 38 times.
38 if(!strcmp(tempheader.new_version_devsig, "Venrob"))
2641 strcpy(tempheader.new_version_devsig, "EmilyV99");
2642
1/2
✓ Branch 0 taken 38 times.
✗ Branch 1 not taken.
38 if(!pfread(tempheader.new_version_compilername,256,f))
2643 {
2644 return qe_invalid;
2645 }
2646
1/2
✓ Branch 0 taken 38 times.
✗ Branch 1 not taken.
38 if(!pfread(tempheader.new_version_compilerversion,256,f))
2647 {
2648 return qe_invalid;
2649 }
2650
1/2
✓ Branch 0 taken 38 times.
✗ Branch 1 not taken.
38 if(!pfread(tempheader.product_name,1024,f))
2651 {
2652 return qe_invalid;
2653 }
2654
2655
1/2
✓ Branch 0 taken 38 times.
✗ Branch 1 not taken.
38 if(!p_getc(&tempheader.compilerid,f))
2656 {
2657 return qe_invalid;
2658 }
2659
1/2
✓ Branch 0 taken 38 times.
✗ Branch 1 not taken.
38 if(!p_igetl(&tempheader.compilerversionnumber_first,f))
2660 {
2661 return qe_invalid;
2662 }
2663
1/2
✓ Branch 0 taken 38 times.
✗ Branch 1 not taken.
38 if(!p_igetl(&tempheader.compilerversionnumber_second,f))
2664 {
2665 return qe_invalid;
2666 }
2667
1/2
✓ Branch 0 taken 38 times.
✗ Branch 1 not taken.
38 if(!p_igetl(&tempheader.compilerversionnumber_third,f))
2668 {
2669 return qe_invalid;
2670 }
2671
1/2
✓ Branch 0 taken 38 times.
✗ Branch 1 not taken.
38 if(!p_igetl(&tempheader.compilerversionnumber_fourth,f))
2672 {
2673 return qe_invalid;
2674 }
2675
1/2
✓ Branch 0 taken 38 times.
✗ Branch 1 not taken.
38 if(!p_igetw(&tempheader.developerid,f))
2676 {
2677 return qe_invalid;
2678 }
2679
1/2
✓ Branch 0 taken 38 times.
✗ Branch 1 not taken.
38 if(!pfread(tempheader.made_in_module_name,1024,f))
2680 {
2681 return qe_invalid;
2682 }
2683
1/2
✓ Branch 0 taken 38 times.
✗ Branch 1 not taken.
38 if(!pfread(tempheader.build_datestamp,256,f))
2684 {
2685 return qe_invalid;
2686 }
2687
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 38 times.
38 if(!pfread(tempheader.build_timestamp,256,f))
2688 {
2689 return qe_invalid;
2690 }
2691 38 }
2692 else // <4
2693 {
2694 89 tempheader.new_version_id_main = 0;
2695 89 tempheader.new_version_id_second = 0;
2696 89 tempheader.new_version_id_third = 0;
2697 89 tempheader.new_version_id_fourth = 0;
2698 89 tempheader.new_version_id_alpha = 0;
2699 89 tempheader.new_version_id_beta = 0;
2700 89 tempheader.new_version_id_gamma = 0;
2701 89 tempheader.new_version_id_release = 0;
2702 89 tempheader.new_version_id_date_year = 0;
2703 89 tempheader.new_version_id_date_month = 0;
2704 89 tempheader.new_version_id_date_day = 0;
2705 89 tempheader.new_version_id_date_hour = 0;
2706 89 tempheader.new_version_id_date_minute = 0;
2707
2708 89 memset(tempheader.new_version_devsig, 0, 256);
2709 89 memset(tempheader.new_version_compilername, 0, 256);
2710 89 memset(tempheader.new_version_compilerversion, 0, 256);
2711 89 memset(tempheader.product_name, 0, 1024);
2712 89 strcpy(tempheader.product_name, "ZQuest Classic");
2713
2714 89 tempheader.compilerid = 0;
2715 89 tempheader.compilerversionnumber_first = 0;
2716 89 tempheader.compilerversionnumber_second = 0;
2717 89 tempheader.compilerversionnumber_third = 0;
2718 89 tempheader.compilerversionnumber_fourth = 0;
2719 89 tempheader.developerid = 0;
2720
2721 89 memset(tempheader.made_in_module_name, 0, 1024);
2722 89 memset(tempheader.build_datestamp, 0, 256);
2723 89 memset(tempheader.build_timestamp, 0, 256);
2724 }
2725
2726
2/2
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 89 times.
127 if ( version >= 5 )
2727 {
2728
1/2
✓ Branch 0 taken 38 times.
✗ Branch 1 not taken.
38 if(!pfread(tempheader.build_timezone,6,f))
2729 {
2730 return qe_invalid;
2731 }
2732 38 }
2733 else // < 5
2734 {
2735 89 memset(tempheader.build_timezone, 0, 6);
2736 }
2737
2/2
✓ Branch 0 taken 89 times.
✓ Branch 1 taken 38 times.
127 if ( version >= 6 )
2738 {
2739 byte b;
2740
1/2
✓ Branch 0 taken 38 times.
✗ Branch 1 not taken.
38 if(!p_getc(&b,f))
2741 {
2742 return qe_invalid;
2743 }
2744 38 tempheader.external_zinfo = b?true:false;
2745 38 read_zinfo = true;
2746 38 }
2747
2748
2/2
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 89 times.
127 if(version >= 7)
2749 {
2750
1/2
✓ Branch 0 taken 38 times.
✗ Branch 1 not taken.
38 if(!p_getc(&(tempheader.new_version_is_nightly),f))
2751 {
2752 return qe_invalid;
2753 }
2754 38 }
2755 else
2756 {
2757 89 tempheader.new_version_is_nightly = false;
2758
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 89 times.
89 if(tempheader.zelda_version < 0x255)
2759 {
2760
2/5
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 77 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 12 times.
89 switch(tempheader.zelda_version)
2761 {
2762 case 0x254:
2763 tempheader.new_version_id_main = 2;
2764 tempheader.new_version_id_second = 54;
2765 break;
2766 case 0x250:
2767
6/16
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 22 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 5 times.
✓ Branch 11 taken 24 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 15 times.
✓ Branch 14 taken 10 times.
✓ Branch 15 taken 1 times.
77 switch(tempheader.build)
2768 {
2769 case 19:
2770 tempheader.new_version_id_main = 2;
2771 tempheader.new_version_id_second = 50;
2772 tempheader.new_version_id_gamma = 1;
2773 break;
2774 case 20:
2775 tempheader.new_version_id_main = 2;
2776 tempheader.new_version_id_second = 50;
2777 tempheader.new_version_id_gamma = 2;
2778 break;
2779 case 21:
2780 tempheader.new_version_id_main = 2;
2781 tempheader.new_version_id_second = 50;
2782 tempheader.new_version_id_gamma = 3;
2783 break;
2784 case 22:
2785 tempheader.new_version_id_main = 2;
2786 tempheader.new_version_id_second = 50;
2787 tempheader.new_version_id_gamma = 4;
2788 break;
2789 case 23:
2790 tempheader.new_version_id_main = 2;
2791 tempheader.new_version_id_second = 50;
2792 tempheader.new_version_id_gamma = 5;
2793 break;
2794 case 24:
2795 22 tempheader.new_version_id_main = 2;
2796 22 tempheader.new_version_id_second = 50;
2797 22 tempheader.new_version_id_release = -1;
2798 22 break;
2799 case 25:
2800 tempheader.new_version_id_main = 2;
2801 tempheader.new_version_id_second = 50;
2802 tempheader.new_version_id_third = 1;
2803 tempheader.new_version_id_gamma = 1;
2804 break;
2805 case 26:
2806 tempheader.new_version_id_main = 2;
2807 tempheader.new_version_id_second = 50;
2808 tempheader.new_version_id_third = 1;
2809 tempheader.new_version_id_gamma = 2;
2810 break;
2811 case 27:
2812 tempheader.new_version_id_main = 2;
2813 tempheader.new_version_id_second = 50;
2814 tempheader.new_version_id_third = 1;
2815 tempheader.new_version_id_gamma = 3;
2816 break;
2817 case 28:
2818 5 tempheader.new_version_id_main = 2;
2819 5 tempheader.new_version_id_second = 50;
2820 5 tempheader.new_version_id_third = 1;
2821 5 tempheader.new_version_id_release = -1;
2822 5 break;
2823 case 29:
2824 24 tempheader.new_version_id_main = 2;
2825 24 tempheader.new_version_id_second = 50;
2826 24 tempheader.new_version_id_third = 2;
2827 24 tempheader.new_version_id_release = -1;
2828 24 break;
2829 case 30:
2830 tempheader.new_version_id_main = 2;
2831 tempheader.new_version_id_second = 50;
2832 tempheader.new_version_id_third = 3;
2833 tempheader.new_version_id_gamma = 1;
2834 break;
2835 case 31:
2836 15 tempheader.new_version_id_main = 2;
2837 15 tempheader.new_version_id_second = 53;
2838 15 tempheader.new_version_id_gamma = -1;
2839 15 break;
2840 case 32:
2841 10 tempheader.new_version_id_main = 2;
2842 10 tempheader.new_version_id_second = 53;
2843 10 tempheader.new_version_id_release = -1;
2844 10 break;
2845 case 33:
2846 1 tempheader.new_version_id_main = 2;
2847 1 tempheader.new_version_id_second = 53;
2848 1 tempheader.new_version_id_third = 1;
2849 1 break;
2850 }
2851 77 break;
2852
2853 case 0x211:
2854 tempheader.new_version_id_main = 2;
2855 tempheader.new_version_id_second = 11;
2856 tempheader.new_version_id_beta = tempheader.build;
2857 break;
2858 case 0x210:
2859 12 tempheader.new_version_id_main = 2;
2860 12 tempheader.new_version_id_second = 10;
2861 12 tempheader.new_version_id_beta = tempheader.build;
2862 12 break;
2863 }
2864 89 }
2865 }
2866
2/4
✓ Branch 0 taken 127 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 127 times.
127 if(printmetadata || __isZQuest)
2867 {
2868 print_quest_metadata(tempheader, loading_qst_name, loading_qst_num);
2869 }
2870 }
2871
2872 //{ Version Warning
2873 131 int32_t vercmp = tempheader.compareVer();
2874 131 int32_t astatecmp = compare(int32_t(tempheader.getAlphaState()), ALPHA_STATE);
2875 131 int32_t avercmp = compare(tempheader.getAlphaVer(), ALPHA_VER);
2876
4/6
✓ Branch 0 taken 131 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 38 times.
✓ Branch 3 taken 93 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 38 times.
169 if(vercmp > 0 || (!vercmp &&
2877
2/4
✓ Branch 0 taken 38 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 38 times.
✗ Branch 3 not taken.
38 (astatecmp > 0 || (!astatecmp &&
2878 38 avercmp > 0))))
2879 {
2880 bool r = true;
2881 if(loadquest_report)
2882 {
2883 enter_sys_pal();
2884 AlertDialog("Quest saved in newer version",
2885 "This quest was last saved in a newer version of ZQuest."
2886 " Attempting to load this quest may not work correctly; to"
2887 " avoid issues, try loading this quest in at least '" + std::string(tempheader.getVerStr()) + "'"
2888 "\n\nWould you like to continue loading anyway? (Not recommended)",
2889 [&](bool ret,bool)
2890 {
2891 r = ret;
2892 }).show();
2893 exit_sys_pal();
2894 }
2895 if(!r)
2896 return qe_silenterr;
2897 }
2898
1/2
✓ Branch 0 taken 131 times.
✗ Branch 1 not taken.
131 else if(tempheader.compareDate() > 0)
2899 {
2900 bool r = true;
2901 if(loadquest_report)
2902 {
2903 enter_sys_pal();
2904 AlertDialog("Quest saved in newer build",
2905 fmt::format("This quest was last saved in a newer build of ZQuest, and may have"
2906 " issues loading in this build."
2907 "\n{}"
2908 "\n\nWould you like to continue loading anyway?",
2909 tempheader.getVerCmpStr()),
2910 [&](bool ret,bool)
2911 {
2912 r = ret;
2913 }).show();
2914 exit_sys_pal();
2915 }
2916 if(!r)
2917 return qe_silenterr;
2918 }
2919 //}
2920
2921 131 read_ext_zinfo = tempheader.external_zinfo;
2922
2923 131 memcpy(Header, &tempheader, sizeof(tempheader));
2924 131 map_count=temp_map_count;
2925 131 memcpy(midi_flags, temp_midi_flags, MIDIFLAGS_SIZE);
2926
2927 131 unpack_qrs();
2928
2929 131 return 0;
2930 131 }
2931
2932 131 int32_t readrules(PACKFILE *f, zquestheader *Header)
2933 {
2934
2/2
✓ Branch 0 taken 127 times.
✓ Branch 1 taken 4 times.
131 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_rules);
2935
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 131 times.
131 if (should_skip)
2936 return 0;
2937
2938 int32_t dummy;
2939 zquestheader tempheader;
2940 131 word s_version=0;
2941 131 dword compatrule_version=0;
2942
2943 131 memcpy(&tempheader, Header, sizeof(tempheader));
2944
2945
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 127 times.
131 if(tempheader.zelda_version >= 0x193)
2946 {
2947 //section version info
2948
1/2
✓ Branch 0 taken 127 times.
✗ Branch 1 not taken.
127 if(!p_igetw(&s_version,f))
2949 {
2950 return qe_invalid;
2951 }
2952
2953 127 FFCore.quest_format[vRules] = s_version;
2954
2955
1/2
✓ Branch 0 taken 127 times.
✗ Branch 1 not taken.
127 if(!p_igetw(&dummy,f))
2956 {
2957 return qe_invalid;
2958 }
2959
2960
2/2
✓ Branch 0 taken 89 times.
✓ Branch 1 taken 38 times.
127 if(s_version > 16)
2961 {
2962
1/2
✓ Branch 0 taken 38 times.
✗ Branch 1 not taken.
38 if(!p_igetl(&compatrule_version,f))
2963 {
2964 return qe_invalid;
2965 }
2966 38 }
2967 127 FFCore.quest_format[vCompatRule] = compatrule_version;
2968
2969 //section size
2970
1/2
✓ Branch 0 taken 127 times.
✗ Branch 1 not taken.
127 if(!p_igetl(&dummy,f))
2971 {
2972 return qe_invalid;
2973 }
2974
2975
2/2
✓ Branch 0 taken 89 times.
✓ Branch 1 taken 38 times.
127 if ( s_version < 15 )
2976 {
2977 //finally... section data
2978
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 89 times.
89 if(!pfread(quest_rules,QUESTRULES_SIZE,f))
2979 {
2980 return qe_invalid;
2981 }
2982 89 }
2983 else
2984 {
2985
2986
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 38 times.
38 if(!pfread(quest_rules,QUESTRULES_NEW_SIZE,f))
2987 {
2988 return qe_invalid;
2989 }
2990
2991 }
2992 127 }
2993
2994 //al_trace("Rules version %d\n", s_version);
2995 //{ bunch of compat stuff
2996 131 memcpy(deprecated_rules, quest_rules, QUESTRULES_NEW_SIZE);
2997
2998 131 unpack_qrs();
2999
3000
2/2
✓ Branch 0 taken 115 times.
✓ Branch 1 taken 16 times.
131 if(s_version<2)
3001 {
3002 16 set_qr(14,0);
3003 16 set_qr(27,0);
3004 16 set_qr(28,0);
3005 16 set_qr(29,0);
3006 16 set_qr(30,0);
3007 16 set_qr(32,0);
3008 16 set_qr(36,0);
3009 16 set_qr(49,0);
3010 16 set_qr(50,0);
3011 16 set_qr(51,0);
3012 16 set_qr(68,0);
3013 16 set_qr(75,0);
3014 16 set_qr(76,0);
3015 16 set_qr(98,0);
3016 16 set_qr(110,0);
3017 16 set_qr(113,0);
3018 16 set_qr(116,0);
3019 16 set_qr(102,0);
3020 16 set_qr(132,0);
3021 16 }
3022
3023 //Now, do any updates...
3024
3/6
✓ Branch 0 taken 115 times.
✓ Branch 1 taken 16 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 115 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
131 if((tempheader.zelda_version < 0x211)||((tempheader.zelda_version == 0x211)&&(tempheader.build<18)))
3025 {
3026 16 set_qr(qr_SMOOTHVERTICALSCROLLING,1);
3027 16 set_qr(qr_REPLACEOPENDOORS, 1);
3028 16 set_qr(qr_OLDLENSORDER, 1);
3029 16 set_qr(qr_NOFAIRYGUYFIRES, 1);
3030 16 set_qr(qr_TRIGGERSREPEAT, 1);
3031 16 }
3032
3033
3/6
✓ Branch 0 taken 127 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 127 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
131 if((tempheader.zelda_version < 0x193)||((tempheader.zelda_version == 0x193)&&(tempheader.build<3)))
3034 {
3035 4 set_qr(qr_WALLFLIERS,1);
3036 4 }
3037
3038
3/6
✓ Branch 0 taken 127 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 127 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
131 if((tempheader.zelda_version < 0x193)||((tempheader.zelda_version == 0x193)&&(tempheader.build<4)))
3039 {
3040 4 set_qr(qr_NOBOMBPALFLASH,1);
3041 4 }
3042
3043
5/6
✓ Branch 0 taken 127 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 127 times.
✓ Branch 4 taken 2 times.
✓ Branch 5 taken 2 times.
131 if((tempheader.zelda_version < 0x193)||((tempheader.zelda_version == 0x193)&&(tempheader.build<3)))
3044 {
3045 6 set_qr(qr_NOSCROLLCONTINUE,1);
3046 6 }
3047
3048
2/2
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 16 times.
133 if(tempheader.zelda_version <= 0x210)
3049 {
3050 16 set_qr(qr_ARROWCLIP,1);
3051 16 }
3052
3053
2/2
✓ Branch 0 taken 117 times.
✓ Branch 1 taken 12 times.
129 if(tempheader.zelda_version == 0x210)
3054 {
3055 12 set_qr(qr_NOSCROLLCONTINUE, get_qr(qr_CMBCYCLELAYERS));
3056 12 set_qr(qr_CMBCYCLELAYERS, 0);
3057 12 set_qr(qr_CONT_SWORD_TRIGGERS, 1);
3058 12 }
3059
3060
2/2
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 16 times.
129 if(tempheader.zelda_version <= 0x210)
3061 {
3062 16 set_qr(qr_OLDSTYLEWARP,1);
3063 16 set_qr(qr_210_WARPRETURN,1);
3064 16 }
3065
3066 //might not be correct
3067
2/2
✓ Branch 0 taken 125 times.
✓ Branch 1 taken 4 times.
129 if(tempheader.zelda_version < 0x210)
3068 {
3069 4 set_bit(deprecated_rules, qr_OLDTRIBBLES_DEP,1);
3070 4 set_qr(qr_OLDTRIBBLES_DEP,1);
3071 4 set_qr(qr_OLDHOOKSHOTGRAB,1);
3072 4 }
3073
3074
2/2
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 16 times.
129 if(tempheader.zelda_version < 0x211)
3075 {
3076 16 set_qr(qr_WRONG_BRANG_TRAIL_DIR,1);
3077 16 }
3078
3079
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 129 times.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 125 times.
129 if((tempheader.zelda_version == 0x192 && tempheader.build <= 163) || tempheader.zelda_version < 0x192)
3080 {
3081 4 set_qr(qr_192b163_WARP,1);
3082 4 }
3083
3084
2/2
✓ Branch 0 taken 117 times.
✓ Branch 1 taken 12 times.
129 if(tempheader.zelda_version == 0x210)
3085 {
3086 12 set_bit(deprecated_rules, qr_OLDTRIBBLES_DEP, get_qr(qr_DMGCOMBOPRI));
3087 12 set_qr(qr_OLDTRIBBLES_DEP, get_qr(qr_DMGCOMBOPRI));
3088 12 set_qr(qr_DMGCOMBOPRI, 0);
3089 12 }
3090
3091
5/6
✓ Branch 0 taken 115 times.
✓ Branch 1 taken 14 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 115 times.
✓ Branch 4 taken 2 times.
✓ Branch 5 taken 2 times.
129 if(tempheader.zelda_version < 0x211 || (tempheader.zelda_version == 0x211 && tempheader.build<15))
3092 {
3093 16 set_qr(qr_OLDPICKUP,1);
3094 16 }
3095
3096
5/6
✓ Branch 0 taken 115 times.
✓ Branch 1 taken 14 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 115 times.
✓ Branch 4 taken 2 times.
✓ Branch 5 taken 2 times.
133 if(tempheader.zelda_version < 0x211 || (tempheader.zelda_version == 0x211 && tempheader.build < 18))
3097 {
3098 16 set_qr(qr_NOSOLIDDAMAGECOMBOS, 1);
3099 16 set_qr(qr_ITEMPICKUPSETSBELOW, 1); // broke around build 400
3100 16 }
3101
3102
2/2
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 16 times.
133 if(tempheader.zelda_version < 0x250) // version<0x250 checks for beta 18; build was set to 18 prematurely
3103 {
3104 16 set_qr(qr_HOOKSHOTDOWNBUG, 1);
3105 16 }
3106
3107
4/4
✓ Branch 0 taken 77 times.
✓ Branch 1 taken 52 times.
✓ Branch 2 taken 55 times.
✓ Branch 3 taken 22 times.
129 if(tempheader.zelda_version == 0x250 && tempheader.build == 24) // Annoying...
3108 {
3109 22 set_qr(qr_PEAHATCLOCKVULN, 1);
3110 22 }
3111
3112
6/6
✓ Branch 0 taken 115 times.
✓ Branch 1 taken 14 times.
✓ Branch 2 taken 77 times.
✓ Branch 3 taken 38 times.
✓ Branch 4 taken 2 times.
✓ Branch 5 taken 75 times.
129 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build < 22)) //22 is 2.50.0 RC4. Gotta set the door repair QR... -Dimi
3113 {
3114 16 set_qr(qr_OLD_DOORREPAIR, 1);
3115 16 }
3116
3117
6/6
✓ Branch 0 taken 115 times.
✓ Branch 1 taken 14 times.
✓ Branch 2 taken 77 times.
✓ Branch 3 taken 38 times.
✓ Branch 4 taken 2 times.
✓ Branch 5 taken 79 times.
129 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build < 20)) //20 is 2.50.0 RC1 and RC2 (cause it didn't get bumped). Okay I'm gonna be honest I have no idea if any 2.50 build was available before RC1, but gonna try and cover my ass here -Dimi
3118 {
3119 16 set_qr(qr_OLD_SECRETMONEY, 1);
3120 16 }
3121
3122
6/6
✓ Branch 0 taken 115 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 77 times.
✓ Branch 3 taken 38 times.
✓ Branch 4 taken 20 times.
✓ Branch 5 taken 57 times.
133 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build < 28)) //28 is 2.50.1 final. Potion bug might have been used, I dunno. -Dimi
3123 {
3124 38 set_qr(qr_OLD_POTION_OR_HC, 1);
3125 38 }
3126
3127
6/6
✓ Branch 0 taken 115 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 77 times.
✓ Branch 3 taken 38 times.
✓ Branch 4 taken 20 times.
✓ Branch 5 taken 57 times.
133 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build<28))
3128 {
3129 38 set_qr(qr_OFFSCREENWEAPONS, 1);
3130 38 }
3131
3132 //Bombchu fix.
3133
2/2
✓ Branch 0 taken 56 times.
✓ Branch 1 taken 77 times.
133 if(tempheader.zelda_version == 0x250)
3134 {
3135
2/2
✓ Branch 0 taken 55 times.
✓ Branch 1 taken 22 times.
77 if ( tempheader.build == 24 ) //2.50.0
3136 {
3137 22 set_qr(qr_BOMBCHUSUPERBOMB, 1);
3138 22 }
3139
2/2
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 5 times.
77 if ( tempheader.build == 28 ) //2.50.1
3140 {
3141 5 set_qr(qr_BOMBCHUSUPERBOMB, 1);
3142 5 }
3143
2/2
✓ Branch 0 taken 53 times.
✓ Branch 1 taken 24 times.
77 if ( tempheader.build == 29 ) //2.50.2
3144 {
3145 24 set_qr(qr_BOMBCHUSUPERBOMB, 0);
3146 24 }
3147
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 if ( tempheader.build == 30 ) //2.50.3RC1
3148 {
3149 set_qr(qr_BOMBCHUSUPERBOMB, 0);
3150 }
3151 77 }
3152
3153
6/6
✓ Branch 0 taken 115 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 77 times.
✓ Branch 3 taken 38 times.
✓ Branch 4 taken 25 times.
✓ Branch 5 taken 52 times.
133 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build<29))
3154 {
3155 // qr_OFFSETEWPNCOLLISIONFIX
3156 // All 'official' quests need this disabled.
3157 // All 2.10 and lower quests need this enabled to preseve compatability.
3158 // All 2.11 - 2.5.1 quests should have it set also, due to a bug in about half of all the betas.
3159
3160 //~Gleeok
3161 43 set_qr(qr_OFFSETEWPNCOLLISIONFIX, 1); //This has to be set!!!!
3162
3163 // Broke in build 695
3164
3/4
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 16 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 27 times.
43 if(tempheader.zelda_version>=0x211 && tempheader.build>=18)
3165 27 set_qr(qr_BROKENSTATUES, 1);
3166 43 }
3167
2/2
✓ Branch 0 taken 129 times.
✓ Branch 1 taken 4 times.
133 if (tempheader.zelda_version <= 0x190)
3168 {
3169 4 set_qr(qr_COPIED_SWIM_SPRITES, 1);
3170 4 }
3171
9/10
✓ Branch 0 taken 77 times.
✓ Branch 1 taken 56 times.
✓ Branch 2 taken 55 times.
✓ Branch 3 taken 1 times.
✓ Branch 4 taken 39 times.
✓ Branch 5 taken 16 times.
✓ Branch 6 taken 38 times.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 38 times.
133 if ( (tempheader.zelda_version == 0x250 && tempheader.build < 33) || tempheader.zelda_version == 0x254 || tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x255 && tempheader.build < 50) )
3172 {
3173 94 set_qr(qr_OLD_SLASHNEXT_SECRETS, 1);
3174 94 }
3175
3176
2/2
✓ Branch 0 taken 115 times.
✓ Branch 1 taken 16 times.
131 if ( (tempheader.zelda_version < 0x211) ) //2.10 water and ladder interaction
3177 {
3178 16 set_qr(qr_OLD_210_WATER, 1);
3179 16 }
3180
3181
4/6
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 93 times.
✓ Branch 2 taken 38 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 38 times.
131 if ( (tempheader.zelda_version < 0x255 ) || (tempheader.zelda_version == 0x255 && tempheader.build < 51 ) ) //2.10 water and ladder interaction
3182 {
3183 93 set_qr(qr_STEP_IS_FLOAT,0);
3184 93 }
3185
3186
2/2
✓ Branch 0 taken 115 times.
✓ Branch 1 taken 16 times.
131 if ( tempheader.zelda_version < 0x250 )
3187 {
3188 16 set_qr(qr_8WAY_SHOT_SFX, 1);
3189 16 }
3190
3191
2/2
✓ Branch 0 taken 115 times.
✓ Branch 1 taken 16 times.
131 if(s_version < 3)
3192 {
3193 16 set_qr(qr_HOLDNOSTOPMUSIC, 1);
3194 16 set_qr(qr_CAVEEXITNOSTOPMUSIC, 1);
3195 16 }
3196
3197
2/2
✓ Branch 0 taken 115 times.
✓ Branch 1 taken 16 times.
131 if(s_version<4)
3198 {
3199 16 set_qr(10,0);
3200 16 }
3201
3202
2/2
✓ Branch 0 taken 115 times.
✓ Branch 1 taken 16 times.
131 if(s_version<5)
3203 {
3204 16 set_qr(27,0);
3205 16 }
3206
3207
2/2
✓ Branch 0 taken 115 times.
✓ Branch 1 taken 16 times.
131 if(s_version<6)
3208 {
3209 16 set_qr(46,0);
3210 16 }
3211
3212
2/2
✓ Branch 0 taken 115 times.
✓ Branch 1 taken 16 times.
131 if(s_version<7) // January 2008
3213 {
3214 16 set_qr(qr_HEARTSREQUIREDFIX,0);
3215 16 set_qr(qr_PUSHBLOCKCSETFIX,1);
3216 16 }
3217
3218
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 115 times.
131 if(s_version<8)
3219 {
3220 16 set_qr(12, 0);
3221 16 }
3222 else
3223 {
3224 115 set_bit(deprecated_rules, 12, 0);
3225 }
3226
3227
2/2
✓ Branch 0 taken 115 times.
✓ Branch 1 taken 16 times.
131 if(s_version<9) // October 2008
3228 {
3229 16 set_qr(qr_NOROPE2FLASH_DEP,0);
3230 16 set_qr(qr_NOBUBBLEFLASH_DEP,0);
3231 16 set_qr(qr_GHINI2BLINK_DEP,0);
3232 16 set_qr(qr_PHANTOMGHINI2_DEP,0);
3233 16 }
3234
3235
2/2
✓ Branch 0 taken 115 times.
✓ Branch 1 taken 16 times.
131 if(s_version<10) // December 2008
3236 {
3237 16 set_qr(qr_NOCLOCKS_DEP,0);
3238 16 set_qr(qr_ALLOW10RUPEEDROPS_DEP,0);
3239 16 }
3240
3241
2/2
✓ Branch 0 taken 115 times.
✓ Branch 1 taken 16 times.
131 if(s_version<11) // April 2009
3242 {
3243 16 set_qr(qr_SLOWENEMYANIM_DEP,0);
3244 16 }
3245
3246 // This served no purpose.
3247 // if(s_version<12) // December 2009
3248 // {
3249 // set_qr(qr_BRKBLSHLDS_DEP,0);
3250 // set_qr(qr_OLDTRIBBLES_DEP,0);
3251 // }
3252
3253 //if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build < 24))
3254
2/2
✓ Branch 0 taken 115 times.
✓ Branch 1 taken 16 times.
131 if(s_version < 13)
3255 {
3256 16 set_qr(qr_SHOPCHEAT, 1);
3257 16 }
3258
3259 // Not entirely sure this is the best place for this...
3260 //2.50.2 bitmap offset fix
3261 131 memset(extra_rules, 0, EXTRARULES_SIZE);
3262
6/6
✓ Branch 0 taken 115 times.
✓ Branch 1 taken 16 times.
✓ Branch 2 taken 77 times.
✓ Branch 3 taken 38 times.
✓ Branch 4 taken 27 times.
✓ Branch 5 taken 50 times.
131 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build<29))
3263 {
3264 43 set_er(er_BITMAPOFFSET, 1);
3265 43 set_qr(qr_BITMAPOFFSETFIX, 1);
3266 43 }
3267 //required because quest templates also used this bit, although
3268 //it never did anything, before. -Z
3269
2/2
✓ Branch 0 taken 54 times.
✓ Branch 1 taken 77 times.
131 if ( tempheader.zelda_version == 0x250 )
3270 {
3271
5/6
✓ Branch 0 taken 53 times.
✓ Branch 1 taken 24 times.
✓ Branch 2 taken 53 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 15 times.
✓ Branch 5 taken 38 times.
77 if( tempheader.build == 29 || tempheader.build == 30 || tempheader.build == 31 )
3272 {
3273 39 set_er(er_BITMAPOFFSET, 0);
3274 39 set_qr(qr_BITMAPOFFSETFIX, 0);
3275 39 }
3276 77 }
3277
1/2
✓ Branch 0 taken 131 times.
✗ Branch 1 not taken.
131 if ( tempheader.zelda_version == 0x254 )
3278 {
3279 set_er(er_BITMAPOFFSET, 0);
3280 set_qr(qr_BITMAPOFFSETFIX, 0);
3281 }
3282
3/4
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 93 times.
✓ Branch 2 taken 38 times.
✗ Branch 3 not taken.
131 if ( tempheader.zelda_version == 0x255 && tempheader.build < 42 ) //QR was added to 255 in this build.
3283 {
3284 set_er(er_BITMAPOFFSET, 0);
3285 set_qr(qr_BITMAPOFFSETFIX, 0);
3286 }
3287 //optimise fast drawing for older versions.
3288
4/6
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 93 times.
✓ Branch 2 taken 38 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 38 times.
131 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 42) )
3289 {
3290 93 set_qr(qr_OLDSPRITEDRAWS, 1);
3291 93 }
3292 //Old eweapon->Parent (was added in 2.54, Alpha 19)
3293 //The change was made in build 43, but I'm setting this to < 42, because quests made in 42 would benefit from this change, and
3294 //older quests can set the rule by hand. We need a new qst.dat again.
3295
4/6
✓ Branch 0 taken 131 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 38 times.
✓ Branch 3 taken 93 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 38 times.
131 if ( tempheader.zelda_version == 0x254 || (tempheader.zelda_version == 0x255 && tempheader.build < 42) )
3296 {
3297 set_qr(qr_OLDEWPNPARENT, 1);
3298 }
3299
4/6
✓ Branch 0 taken 131 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 38 times.
✓ Branch 3 taken 93 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 38 times.
131 if ( tempheader.zelda_version == 0x254 || (tempheader.zelda_version == 0x255 && tempheader.build < 44) )
3300 {
3301 set_qr(qr_OLDCREATEBITMAP_ARGS, 1);
3302 }
3303
4/6
✓ Branch 0 taken 131 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 38 times.
✓ Branch 3 taken 93 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 38 times.
131 if ( tempheader.zelda_version == 0x254 || (tempheader.zelda_version == 0x255 && tempheader.build < 45) )
3304 {
3305 set_qr(qr_OLDQUESTMISC, 1);
3306 }
3307
2/2
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 93 times.
131 if ( tempheader.zelda_version < 0x254 )
3308 {
3309 93 set_qr(qr_OLDCREATEBITMAP_ARGS, 0);
3310 93 set_qr(qr_OLDEWPNPARENT, 0);
3311 93 set_qr(qr_OLDQUESTMISC, 0);
3312 93 }
3313
3314 //item scripts continue to run
3315
4/6
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 93 times.
✓ Branch 2 taken 38 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 38 times.
131 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 44) )
3316 {
3317 93 set_qr(qr_ITEMSCRIPTSKEEPRUNNING, 0);
3318 93 set_qr(qr_SCRIPTSRUNINHEROSTEPFORWARD, 0);
3319 93 set_qr(qr_FIXSCRIPTSDURINGSCROLLING, 0);
3320 93 set_qr(qr_SCRIPTDRAWSINWARPS, 0);
3321 93 set_qr(qr_DYINGENEMYESDONTHURTHERO, 0);
3322 93 set_qr(qr_OUTOFBOUNDSENEMIES, 0);
3323 93 set_qr(qr_SPRITEXY_IS_FLOAT, 0);
3324 93 }
3325
3326
4/6
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 93 times.
✓ Branch 2 taken 38 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 38 times.
131 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 46) )
3327 {
3328 93 set_qr(qr_CLEARINITDONSCRIPTCHANGE, 1);
3329 93 }
3330
4/6
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 93 times.
✓ Branch 2 taken 38 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 38 times.
131 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 46) )
3331 {
3332 93 set_qr(qr_TRACESCRIPTIDS, 0);
3333 93 set_qr(qr_SCRIPT_FRIENDLY_ENEMY_TYPES, 1);
3334 93 set_qr(qr_PARSER_BOOL_TRUE_DECIMAL, 1);
3335 93 set_qr(qr_PARSER_250DIVISION,1);
3336 93 set_qr(qr_PARSER_BOOL_TRUE_DECIMAL,1);
3337 93 set_qr(qr_PARSER_TRUE_INT_SIZE,0);
3338 93 set_qr(qr_PARSER_FORCE_INLINE,0);
3339 93 set_qr(qr_PARSER_BINARY_32BIT,0);
3340
2/2
✓ Branch 0 taken 91 times.
✓ Branch 1 taken 2 times.
93 if ( get_qr(qr_SELECTAWPN) )
3341 {
3342 2 set_qr(qr_NO_L_R_BUTTON_INVENTORY_SWAP,1);
3343 //In < 2.55a27, if you had an A+B subscreen, L and R didn't shift through inventory.
3344 //Now they **do**, unless you disable that behaviour.
3345 //For the sake of compatibility, old quests with the A+B subscreen rule enabed
3346 //now enable the disable L/R item swap on load.
3347 2 }
3348
3349 93 }
3350
4/6
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 93 times.
✓ Branch 2 taken 38 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 38 times.
131 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 47) )
3351 {
3352 //Compatibility: Setting the hero's action to rafting was previously disallowed, though legal for scripts to attempt.
3353 93 set_qr(qr_DISALLOW_SETTING_RAFTING, 1);
3354 //Compatibility: The calculation for when to loop an animation did not factor in ASkipY correctly, resulting in
3355 //animations ending earlier than they should.
3356 93 set_qr(qr_BROKEN_ASKIP_Y_FRAMES, 1);
3357 //Enemies would ignore solidity on the top half of combos
3358 93 set_qr(qr_ENEMY_BROKEN_TOP_HALF_SOLIDITY, 1);
3359 //Ceiling collison was a bit wonky, including hitting your head before you are near the ceiling or clipping into it slightly.
3360 93 set_qr(qr_OLD_SIDEVIEW_CEILING_COLLISON, 1);
3361 //If an itemdata had a 'frames' of 0, items created of that data would ignore all changes to 'frames'
3362 93 set_qr(qr_0AFRAME_ITEMS_IGNORE_AFRAME_CHANGES, 1);
3363 //Collision used some odd calculations before, and enemies could not be hit back into the top row or left column
3364 93 set_qr(qr_OLD_ENEMY_KNOCKBACK_COLLISION, 1);
3365 93 }
3366
2/2
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 93 times.
131 if ( tempheader.zelda_version < 0x255 )
3367 {
3368 93 set_qr(qr_NOFFCWAITDRAW, 1);
3369 93 set_qr(qr_NOITEMWAITDRAW, 1);
3370 93 set_qr(qr_SETENEMYWEAPONSPRITESONWPNCHANGE, 1);
3371 93 set_qr(qr_OLD_INIT_SCRIPT_TIMING, 1);
3372 //set_qr(qr_DO_NOT_DEALLOCATE_INIT_AND_SAVELOAD_ARRAYS, 1);
3373 93 }
3374
4/6
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 93 times.
✓ Branch 2 taken 38 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 38 times.
131 if ( tempheader.zelda_version < 0x255 || ( tempheader.zelda_version == 0x255 && tempheader.build < 48 ) )
3375 {
3376 93 set_qr(qr_SETENEMYWEAPONSPRITESONWPNCHANGE, 1);
3377 93 }
3378
4/6
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 93 times.
✓ Branch 2 taken 38 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 38 times.
131 if( tempheader.zelda_version < 0x255 || ( tempheader.zelda_version == 0x255 && tempheader.build < 52 ) )
3379 {
3380 93 set_qr(qr_OLD_PRINTF_ARGS, 1);
3381 93 }
3382
3383
3384
4/6
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 93 times.
✓ Branch 2 taken 38 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 38 times.
131 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 54) )
3385 {
3386 93 set_qr(qr_BROKEN_RING_POWER, 1);
3387 93 }
3388
4/6
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 93 times.
✓ Branch 2 taken 38 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 38 times.
131 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 56) )
3389 {
3390 93 set_qr(qr_NO_OVERWORLD_MAP_CHARTING, 1);
3391 93 }
3392
4/6
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 93 times.
✓ Branch 2 taken 38 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 38 times.
131 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 57) )
3393 {
3394 93 set_qr(qr_DUNGEONS_USE_CLASSIC_CHARTING, 1);
3395 93 }
3396
4/6
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 93 times.
✓ Branch 2 taken 38 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 38 times.
131 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 58) )
3397 {
3398 //Rule used to be 'qr_SETXYBUTTONITEMS', now split.
3399
1/2
✓ Branch 0 taken 93 times.
✗ Branch 1 not taken.
93 if(get_qr(qr_SET_XBUTTON_ITEMS))
3400 set_qr(qr_SET_YBUTTON_ITEMS,1);
3401 93 }
3402
4/6
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 93 times.
✓ Branch 2 taken 38 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 38 times.
131 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 59) )
3403 {
3404 93 set_qr(qr_ALLOW_EDITING_COMBO_0,1);
3405 93 }
3406
4/6
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 93 times.
✓ Branch 2 taken 38 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 38 times.
131 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 60) )
3407 {
3408 93 set_qr(qr_OLD_CHEST_COLLISION,1);
3409 93 }
3410
3411
2/2
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 93 times.
131 if ( tempheader.zelda_version < 0x254 )
3412 {
3413 93 set_qr(qr_250WRITEEDEFSCRIPT, 1);
3414 93 }
3415 //Sideview spikes in 2.50.0
3416
6/6
✓ Branch 0 taken 115 times.
✓ Branch 1 taken 16 times.
✓ Branch 2 taken 77 times.
✓ Branch 3 taken 38 times.
✓ Branch 4 taken 22 times.
✓ Branch 5 taken 55 times.
131 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build<27)) //2.50.1RC3
3417 {
3418 38 set_qr(qr_OLDSIDEVIEWSPIKES, 1);
3419 38 }
3420 //more 2.50 fixes -Z
3421
6/6
✓ Branch 0 taken 115 times.
✓ Branch 1 taken 16 times.
✓ Branch 2 taken 77 times.
✓ Branch 3 taken 38 times.
✓ Branch 4 taken 51 times.
✓ Branch 5 taken 26 times.
131 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build<31))
3422 {
3423 67 set_qr(qr_MELEEMAGICCOST, 0);
3424 67 set_qr(qr_GANONINTRO, 0); //This will get flipped later on in the compatrule 11 check. That's why it's turning it off.
3425 67 set_qr(qr_OLDMIRRORCOMBOS, 1);
3426 67 set_qr(qr_BROKENBOOKCOST, 1);
3427 67 set_qr(qr_BROKENCHARINTDRAWING, 1);
3428
3429 67 }
3430
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 131 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
131 if(tempheader.zelda_version == 0x254 && tempheader.build<41)
3431 {
3432 //set_qr(qr_MELEEMAGICCOST, get_er(er_MAGICCOSTSWORD));
3433 set_qr(qr_MELEEMAGICCOST, 1);
3434 }
3435
3436
2/2
✓ Branch 0 taken 127 times.
✓ Branch 1 taken 4 times.
131 if(tempheader.zelda_version < 0x193)
3437 {
3438 4 set_qr(qr_SHORTDGNWALK, 1);
3439 4 }
3440
3441
2/2
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 93 times.
131 if(tempheader.zelda_version < 0x255)
3442 {
3443 93 set_qr(qr_OLDINFMAGIC, 1);
3444 93 }
3445
3446
2/2
✓ Branch 0 taken 115 times.
✓ Branch 1 taken 16 times.
131 if((tempheader.zelda_version < 0x250)) //2.10 and earlier allowed the triforce to Warp Player out of Item Cellars in Dungeons. -Z (15th March, 2019 )
3447 {
3448 16 set_qr(qr_SIDEVIEWTRIFORCECELLAR,1);
3449 16 }
3450
3451
4/6
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 93 times.
✓ Branch 2 taken 38 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 38 times.
131 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 47) )
3452 {
3453 93 set_qr(qr_OLD_F6,1);
3454 93 }
3455
4/6
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 93 times.
✓ Branch 2 taken 38 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 38 times.
131 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 49) )
3456 {
3457 93 set_qr(qr_NO_OVERWRITING_HOPPING,1);
3458 93 }
3459
4/6
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 93 times.
✓ Branch 2 taken 38 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 38 times.
131 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 50) )
3460 {
3461 93 set_qr(qr_STRING_FRAME_OLD_WIDTH_HEIGHT,1);
3462 93 }
3463
4/6
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 93 times.
✓ Branch 2 taken 38 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 38 times.
131 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 53) )
3464 {
3465 93 set_qr(qr_BROKEN_OVERWORLD_MINIMAP,1);
3466 93 }
3467 //}
3468
3469
2/2
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 93 times.
131 if(compatrule_version < 1) //Enemies->Secret only affects flag 16-31
3470 93 set_qr(qr_ENEMIES_SECRET_ONLY_16_31,1);
3471
3472
2/2
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 93 times.
131 if(compatrule_version < 2) //Old CSet2 Handling
3473 93 set_qr(qr_OLDCS2,1);
3474
3475
2/2
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 93 times.
131 if(compatrule_version < 3) //Hardcoded Shadow/Spawn/Death anim frames
3476 93 set_qr(qr_HARDCODED_ENEMY_ANIMS,1);
3477
3478
2/2
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 93 times.
131 if(compatrule_version < 4) //Hardcoded Shadow/Spawn/Death anim frames
3479 93 set_qr(qr_OLD_ITEMDATA_SCRIPT_TIMING,1);
3480
3481
4/4
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 38 times.
✓ Branch 2 taken 16 times.
✓ Branch 3 taken 77 times.
131 if(compatrule_version < 5 && tempheader.zelda_version >= 0x250) //Hardcoded Shadow/Spawn/Death anim frames
3482 77 set_qr(qr_NO_LANMOLA_RINGLEADER,1);
3483
3484
2/2
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 93 times.
131 if(compatrule_version < 6) //Step->Secret (Temp) only affects flag 16-31
3485 93 set_qr(qr_STEPTEMP_SECRET_ONLY_16_31,1);
3486
3487
2/2
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 93 times.
131 if(compatrule_version < 7) //'Hit All Triggers->Perm Secret' doesn't trigger temp secrets
3488 93 set_qr(qr_ALLTRIG_PERMSEC_NO_TEMP,1);
3489
3490
2/2
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 93 times.
131 if(compatrule_version < 8) //Hardcoded LItem/Bomb/Clock/Magic Tile Mods
3491 93 set_qr(qr_HARDCODED_LITEM_LTMS,1);
3492
3493
2/2
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 93 times.
131 if(compatrule_version < 9)
3494 {
3495 //Hardcoded BS Patras
3496 93 set_qr(qr_HARDCODED_BS_PATRA,1);
3497 //Hardcoded Patra Inner Eye offsets
3498 93 set_qr(qr_PATRAS_USE_HARDCODED_OFFSETS,1);
3499 //Broken 'Big enemy' animation style
3500 93 set_qr(qr_BROKEN_BIG_ENEMY_ANIMATION,1);
3501 //Broken Attribute 31/32
3502 93 set_qr(qr_BROKEN_ATTRIBUTE_31_32,1);
3503 93 }
3504
3505
2/2
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 93 times.
131 if(compatrule_version < 10) //Shared candle use limits
3506 93 set_qr(qr_CANDLES_SHARED_LIMIT,1);
3507
3508
2/2
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 93 times.
131 if(compatrule_version < 11) //No cross-screen return points
3509 93 set_qr(qr_OLD_RESPAWN_POINTS,1);
3510
3511
2/2
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 93 times.
131 if(compatrule_version < 12)
3512 {
3513 //Old fire trail duration
3514 93 set_qr(qr_OLD_FLAMETRAIL_DURATION,1);
3515 //Old Intro String in Ganon Room Behavior
3516
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 93 times.
93 if(get_qr(qr_GANONINTRO)) set_qr(qr_GANONINTRO,0);
3517 93 else set_qr(qr_GANONINTRO,1);
3518 93 }
3519
3520
3/4
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 38 times.
✓ Branch 2 taken 93 times.
✗ Branch 3 not taken.
131 if(compatrule_version < 13 && tempheader.zelda_version >= 0x255) //ANone doesn't reset to originaltile
3521 set_qr(qr_ANONE_NOANIM,1);
3522
3523
2/2
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 93 times.
131 if(compatrule_version < 14) //Old Bridge Combo Behavior
3524 93 set_qr(qr_OLD_BRIDGE_COMBOS,1);
3525
3526
2/2
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 93 times.
131 if(compatrule_version < 15) //Broken Z3 Animation
3527 93 set_qr(qr_BROKEN_Z3_ANIMATION,1);
3528
3529
2/2
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 93 times.
131 if(compatrule_version < 16) //Old Enemy Tile Behavior with Animation (None) Enemies
3530 93 set_qr(qr_OLD_TILE_INITIALIZATION,1);
3531
3532
2/2
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 93 times.
131 if(compatrule_version < 17)
3533 {
3534 //Old Quake/DrawYOffset behavior
3535 //set_qr(qr_OLD_DRAWOFFSET,1);
3536 //I'm leaving this commented cause I doubt it'll break anything and I think the bugfix might be appreciated in older versions.
3537 //On the offchance that it *does* break old quests, fixing it is as simple as uncommenting the set_bit above.
3538 93 }
3539
3540
2/2
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 93 times.
131 if(compatrule_version < 18)
3541 {
3542 //Broken DrawScreen Derivative Functions
3543 93 set_qr(qr_BROKEN_DRAWSCREEN_FUNCTIONS,1);
3544 //Scrolling Cancels Charge
3545 93 set_qr(qr_SCROLLING_KILLS_CHARGE,1);
3546 93 }
3547
3548
2/2
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 93 times.
131 if(compatrule_version < 19) //Broken Enemy Item Carrying with Large Enemies
3549 93 set_qr(qr_BROKEN_ITEM_CARRYING,1);
3550
3551
2/2
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 93 times.
131 if(compatrule_version < 20)
3552 93 set_qr(qr_CUSTOMWEAPON_IGNORE_COST,1);
3553
3554
2/2
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 93 times.
131 if(compatrule_version < 21)
3555 {
3556 93 set_qr(qr_LEEVERS_DONT_OBEY_STUN,1);
3557 93 set_qr(qr_GANON_CANT_SPAWN_ON_CONTINUE,1);
3558 93 set_qr(qr_WIZZROBES_DONT_OBEY_STUN,1);
3559 93 set_qr(qr_OLD_BUG_NET,1);
3560 93 set_qr(qr_MANHANDLA_BLOCK_SFX,1);
3561 93 }
3562
3563
2/2
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 93 times.
131 if(compatrule_version < 22)
3564 93 set_qr(qr_BROKEN_KEEPOLD_FLAG,1);
3565
3566
2/2
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 93 times.
131 if(compatrule_version < 23)
3567 93 set_qr(qr_OLD_HALF_MAGIC,1);
3568
3569
2/2
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 93 times.
131 if(compatrule_version < 24)
3570 {
3571 93 set_qr(qr_WARPS_RESTART_DMAPSCRIPT,1);
3572 93 set_qr(qr_DMAP_0_CONTINUE_BUG,1);
3573 93 }
3574
3575
2/2
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 93 times.
131 if(compatrule_version < 25)
3576 {
3577
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 93 times.
93 if (get_qr(qr_OLD_FAIRY_LIMIT)) set_qr(qr_OLD_FAIRY_LIMIT,0);
3578 93 else set_qr(qr_OLD_FAIRY_LIMIT,1);
3579 93 set_qr(qr_OLD_SCRIPTED_KNOCKBACK,1);
3580 93 }
3581
2/2
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 93 times.
131 if(compatrule_version < 26)
3582 {
3583 93 set_qr(qr_OLD_KEESE_Z_AXIS,1);
3584 93 set_qr(qr_POLVIRE_NO_SHADOW,1);
3585 93 set_qr(qr_SUBSCR_OLD_SELECTOR,1);
3586 93 }
3587
2/2
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 93 times.
131 if(compatrule_version < 27) //Noticed some junk data in the QR array...
3588 {
3589
2/2
✓ Branch 0 taken 27993 times.
✓ Branch 1 taken 93 times.
28086 for(auto q = qr_POLVIRE_NO_SHADOW+1; q < qr_PARSER_250DIVISION; ++q)
3590 27993 set_qr(q,0);
3591
2/2
✓ Branch 0 taken 186 times.
✓ Branch 1 taken 93 times.
279 for(auto q = qr_COMBODATA_INITD_MULT_TENK+1; q < qr_MAX; ++q)
3592 186 set_qr(q,0);
3593 //This should nuke any remaining junk data... not sure if it affected anything previous. -Em
3594 93 }
3595
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 95 times.
131 if(compatrule_version < 28)
3596 95 set_qr(qr_SUBSCR_BACKWARDS_ID_ORDER,1);
3597
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 95 times.
131 if(compatrule_version < 29)
3598 95 set_qr(qr_OLD_LOCKBLOCK_COLLISION,1);
3599
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 95 times.
131 if(compatrule_version < 30)
3600 {
3601 95 set_qr(qr_DECO_2_YOFFSET,1);
3602 95 set_qr(qr_SCREENSTATE_80s_BUG,1);
3603 95 }
3604
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 95 times.
131 if(compatrule_version < 31)
3605 {
3606 95 set_qr(qr_GOHMA_UNDAMAGED_BUG,1);
3607 95 set_qr(qr_FFCPRELOAD_BUGGED_LOAD,1);
3608 95 }
3609
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 95 times.
131 if(compatrule_version < 32)
3610 95 set_qr(qr_BROKEN_GETPIXEL_VALUE,1);
3611
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 95 times.
131 if(compatrule_version < 33)
3612 95 set_qr(qr_NO_LIFT_SPRITE,1);
3613
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 95 times.
131 if(compatrule_version < 34)
3614 {
3615 95 set_qr(qr_OLD_SIDEVIEW_LANDING_CODE,1);
3616 95 set_qr(qr_OLD_FFC_SPEED_CAP,1);
3617 95 set_qr(qr_OLD_FFC_FUNCTIONALITY,1);
3618 95 set_qr(qr_OLD_WIZZROBE_SUBMERGING,1);
3619 95 }
3620
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 96 times.
131 if(compatrule_version < 35)
3621 {
3622 96 set_qr(qr_ZS_NO_NEG_ARRAY,1);
3623 96 set_qr(qr_BROKEN_INPUT_DOWN_STATE,1);
3624 96 }
3625
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 96 times.
131 if(compatrule_version < 36)
3626 96 set_qr(qr_OLD_SHALLOW_SFX,1);
3627
2/2
✓ Branch 0 taken 33 times.
✓ Branch 1 taken 98 times.
131 if(compatrule_version < 37)
3628 98 set_qr(qr_SPARKLES_INHERIT_PROPERTIES,1);
3629
2/2
✓ Branch 0 taken 33 times.
✓ Branch 1 taken 98 times.
131 if(compatrule_version < 38)
3630 98 set_qr(qr_BUGGED_LAYERED_FLAGS,1);
3631
2/2
✓ Branch 0 taken 33 times.
✓ Branch 1 taken 98 times.
131 if(compatrule_version < 39)
3632 98 set_qr(qr_HARDCODED_FFC_BUSH_DROPS,1);
3633
2/2
✓ Branch 0 taken 33 times.
✓ Branch 1 taken 98 times.
131 if(compatrule_version < 40)
3634 98 set_qr(qr_MOVINGBLOCK_FAKE_SOLID,1);
3635
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 99 times.
131 if(compatrule_version < 41)
3636 99 set_qr(qr_BROKENHITBY,1);
3637
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 99 times.
131 if(compatrule_version < 42)
3638 99 set_qr(qr_BROKEN_MOVING_BOMBS,1);
3639
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 99 times.
131 if(compatrule_version < 43)
3640 99 set_qr(qr_OLD_BOMB_HITBOXES,1);
3641
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 99 times.
131 if(compatrule_version < 44)
3642 99 set_qr(qr_SCROLLWARP_NO_RESET_FRAME,1);
3643
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 99 times.
131 if(compatrule_version < 45)
3644 99 set_qr(qr_ENEMIES_DONT_SCRIPT_FIRST_FRAME,1);
3645
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 99 times.
131 if(compatrule_version < 46)
3646 99 set_qr(qr_BROKEN_RAFT_SCROLL,1);
3647
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 102 times.
131 if(compatrule_version < 47)
3648 {
3649 102 set_qr(qr_SENSITIVE_SOLID_DAMAGE,1);
3650 102 set_qr(qr_OLD_CONVEYOR_COLLISION,1);
3651 102 }
3652
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 102 times.
131 if(compatrule_version < 48)
3653 102 set_qr(qr_OLD_GUY_HANDLING,1);
3654
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 102 times.
131 if(compatrule_version < 49)
3655 102 set_qr(qr_FAIRY_FLAG_COMPAT,1);
3656
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 102 times.
131 if(compatrule_version < 50)
3657 102 set_qr(qr_OLD_LENS_LAYEREFFECT,1);
3658
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 102 times.
131 if(compatrule_version < 51)
3659 102 set_qr(qr_PUSHBLOCK_SPRITE_LAYER,1);
3660
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 102 times.
131 if (compatrule_version < 52)
3661 102 set_qr(qr_OLD_SCRIPT_VOLUME, 1);
3662
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 102 times.
131 if(compatrule_version < 53)
3663 {
3664 102 set_qr(qr_OLD_SUBSCR,1);
3665 102 set_qr(qr_ITM_0_INVIS_ON_BTNS,1);
3666 102 set_qr(qr_OLD_GAUGE_TILE_LAYOUT,1);
3667 102 }
3668
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 102 times.
131 if(compatrule_version < 54)
3669 102 set_qr(qr_WALKTHROUGHWALL_NO_DOORSTATE,1);
3670
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 102 times.
131 if(compatrule_version < 55)
3671 102 set_qr(qr_SPOTLIGHT_IGNR_SOLIDOBJ,1);
3672
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 102 times.
131 if(compatrule_version < 56)
3673 102 set_qr(qr_BROKEN_LIGHTBEAM_HITBOX,1);
3674
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 102 times.
131 if(compatrule_version < 57)
3675 102 set_qr(qr_BROKEN_SWORD_SPIN_TRIGGERS,1);
3676
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 102 times.
131 if(compatrule_version < 58)
3677 102 set_qr(qr_OLD_DMAP_INTRO_STRINGS,1);
3678
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 102 times.
131 if(compatrule_version < 59)
3679 102 set_qr(qr_SCRIPT_CONTHP_IS_HEARTS,1);
3680
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 123 times.
131 if(compatrule_version < 60)
3681 123 set_qr(qr_SEPARATE_BOMBABLE_TAPPING_SFX,1);
3682
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 123 times.
131 if(compatrule_version < 61)
3683 123 set_qr(qr_BROKEN_BOMB_AMMO_COSTS,1);
3684
3685 131 set_qr(qr_ANIMATECUSTOMWEAPONS,0);
3686
2/2
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 93 times.
131 if (s_version < 16)
3687 93 set_qr(qr_BROKEN_HORIZONTAL_WEAPON_ANIM,1);
3688
3689 131 memcpy(Header, &tempheader, sizeof(tempheader));
3690
3691 131 return 0;
3692 131 }
3693
3694 1100830 void init_msgstr(MsgStr *str)
3695 {
3696 1100830 str->s = "";
3697 1100830 str->s.shrink_to_fit();
3698 1100830 str->nextstring=0;
3699 1100830 str->tile=0;
3700 1100830 str->cset=0;
3701 1100830 str->trans=false;
3702 1100830 str->font=font_zfont;
3703 1100830 str->y=32;
3704 1100830 str->sfx=18;
3705 1100830 str->listpos=0;
3706 1100830 str->x=24;
3707 1100830 str->w=get_qr(qr_STRING_FRAME_OLD_WIDTH_HEIGHT)!=0 ? 24*8 : 26*8;
3708 1100830 str->h=get_qr(qr_STRING_FRAME_OLD_WIDTH_HEIGHT)!=0 ? 3*8 : 5*8;
3709 1100830 str->hspace=0;
3710 1100830 str->vspace=0;
3711 1100830 str->stringflags=0;
3712 1100830 str->margins[up] = 8;
3713 1100830 str->margins[down] = 0;
3714 1100830 str->margins[left] = 8;
3715 1100830 str->margins[right] = 0;
3716 1100830 str->portrait_tile = 0;
3717 1100830 str->portrait_cset = 0;
3718 1100830 str->portrait_x = 0;
3719 1100830 str->portrait_y = 0;
3720 1100830 str->portrait_tw = 1;
3721 1100830 str->portrait_th = 1;
3722 1100830 str->shadow_type = 0;
3723 1100830 str->shadow_color = 0;
3724 1100830 str->drawlayer = 6;
3725 1100830 }
3726
3727 131 void init_msgstrings(int32_t start, int32_t end)
3728 {
3729
2/4
✓ Branch 0 taken 131 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 131 times.
131 if(end <= start || end-start > msg_strings_size)
3730 return;
3731
3732
2/2
✓ Branch 0 taken 1073152 times.
✓ Branch 1 taken 131 times.
1073283 for(int32_t i=start; i<end; i++)
3733 {
3734 1073152 init_msgstr(&MsgStrings[i]);
3735 1073152 MsgStrings[i].listpos=i;
3736 1073152 }
3737
3738
1/2
✓ Branch 0 taken 131 times.
✗ Branch 1 not taken.
131 if(start==0)
3739 {
3740 131 MsgStrings[0].s = "(None)";
3741 131 MsgStrings[0].listpos = 0;
3742 131 }
3743 131 }
3744
3745 131 int32_t readstrings(PACKFILE *f, zquestheader *Header)
3746 {
3747
2/2
✓ Branch 0 taken 127 times.
✓ Branch 1 taken 4 times.
131 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_strings);
3748
3749 131 MsgStr tempMsgString;
3750
1/2
✓ Branch 0 taken 131 times.
✗ Branch 1 not taken.
131 init_msgstr(&tempMsgString);
3751
3752 131 word temp_msg_count=0;
3753 word temp_expansion[16];
3754 131 memset(temp_expansion, 0, 16*sizeof(word));
3755 131 char buf[8193] = {0};
3756
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 127 times.
131 if(Header->zelda_version < 0x193)
3757 {
3758 byte tempbyte;
3759 4 int32_t strings_to_read=0;
3760
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if (!should_skip)
3761
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 set_qr(qr_OLD_STRING_EDITOR_MARGINS,true);
3762
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4 if((Header->zelda_version < 0x192)||
3763 ((Header->zelda_version == 0x192)&&(Header->build<31)))
3764 {
3765 4 strings_to_read=128;
3766 4 temp_msg_count=Header->old_str_count;
3767
3768 // Some sort of string count corruption seems to be common in old quests
3769
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(temp_msg_count>128)
3770 {
3771 temp_msg_count=128;
3772 }
3773 4 }
3774 else if((Header->zelda_version == 0x192)&&(Header->build<140))
3775 {
3776 strings_to_read=255;
3777 temp_msg_count=Header->old_str_count;
3778 }
3779 else
3780 {
3781 if(!p_igetw(&temp_msg_count,f))
3782 {
3783 return qe_invalid;
3784 }
3785
3786 strings_to_read=temp_msg_count;
3787
3788 if (!should_skip && temp_msg_count >= msg_strings_size)
3789 {
3790 Z_message("Reallocating string buffer...\n");
3791
3792 // if((MsgStrings=(MsgStr*)_al_sane_realloc(MsgStrings,sizeof(MsgStr)*MAXMSGS))==NULL)
3793 // return qe_nomem;
3794
3795 //memset(MsgStrings, 0, sizeof(MsgStr)*MAXMSGS);
3796 delete[] MsgStrings;
3797 MsgStrings = new MsgStr[MAXMSGS];
3798 msg_strings_size = MAXMSGS;
3799 for(auto q = 0; q < msg_strings_size; ++q)
3800 {
3801 MsgStrings[q].clear();
3802 }
3803 }
3804 }
3805
3806 //reset the message strings
3807
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if (!should_skip)
3808
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 init_msgstrings(0,msg_strings_size);
3809
3810
2/2
✓ Branch 0 taken 512 times.
✓ Branch 1 taken 4 times.
516 for(int32_t x=0; x<strings_to_read; x++)
3811 {
3812
1/2
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
512 init_msgstr(&tempMsgString);
3813 512 tempMsgString.listpos = x;
3814
3815
2/4
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 512 times.
✗ Branch 3 not taken.
512 if(!pfread(buf,73,f))
3816 {
3817 return qe_invalid;
3818 }
3819
3820 512 buf[74] = '\0';
3821
1/2
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
512 tempMsgString.s = buf;
3822
3823
2/4
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 512 times.
✗ Branch 3 not taken.
512 if(!p_getc(&tempbyte,f))
3824 {
3825 return qe_invalid;
3826 }
3827
3828
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 512 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
512 if((Header->zelda_version < 0x192)||
3829 ((Header->zelda_version == 0x192)&&(Header->build<148)))
3830 {
3831
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 512 times.
512 tempMsgString.nextstring=tempbyte?x+1:0;
3832
3833
2/4
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 512 times.
✗ Branch 3 not taken.
512 if(!p_getc(&tempbyte,f))
3834 {
3835 return qe_invalid;
3836 }
3837
3838
2/4
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 512 times.
✗ Branch 3 not taken.
512 if(!p_getc(&tempbyte,f))
3839 {
3840 return qe_invalid;
3841 }
3842 512 }
3843 else
3844 {
3845 if(!p_igetw(&tempMsgString.nextstring,f))
3846 {
3847 return qe_invalid;
3848 }
3849
3850 if(!pfread(temp_expansion,32,f))
3851 {
3852 return qe_invalid;
3853 }
3854 }
3855
3856
1/2
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
512 if (!should_skip)
3857
1/2
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
512 MsgStrings[x] = tempMsgString;
3858 512 }
3859 4 }
3860 else
3861 {
3862 int32_t dummy_int;
3863 word s_version;
3864 word s_cversion;
3865
3866 //section version info
3867
2/4
✓ Branch 0 taken 127 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 127 times.
✗ Branch 3 not taken.
127 if(!p_igetw(&s_version,f))
3868 {
3869 return qe_invalid;
3870 }
3871
3872 127 FFCore.quest_format[vStrings] = s_version;
3873
3874
2/4
✓ Branch 0 taken 127 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 127 times.
✗ Branch 3 not taken.
127 if(!p_igetw(&s_cversion,f))
3875 {
3876 return qe_invalid;
3877 }
3878
3879 //al_trace("Strings version %d\n", s_version);
3880 //section size
3881
2/4
✓ Branch 0 taken 127 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 127 times.
✗ Branch 3 not taken.
127 if(!p_igetl(&dummy_int,f))
3882 {
3883 return qe_invalid;
3884 }
3885
3886 //finally... section data
3887
2/4
✓ Branch 0 taken 127 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 127 times.
✗ Branch 3 not taken.
127 if(!p_igetw(&temp_msg_count,f))
3888 {
3889 return qe_invalid;
3890 }
3891
3892
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 127 times.
127 if(temp_msg_count >= msg_strings_size)
3893 {
3894 Z_message("Reallocating string buffer...\n");
3895
3896 // if((MsgStrings=(MsgStr*)_al_sane_realloc(MsgStrings,sizeof(MsgStr)*MAXMSGS))==NULL)
3897 // return qe_nomem;
3898 delete[] MsgStrings;
3899 MsgStrings = new MsgStr[MAXMSGS];
3900 msg_strings_size = MAXMSGS;
3901 for(auto q = 0; q < msg_strings_size; ++q)
3902 {
3903 MsgStrings[q].clear();
3904 }
3905 //memset(MsgStrings, 0, sizeof(MsgStr)*MAXMSGS);
3906 }
3907
3908 //reset the message strings
3909
2/2
✓ Branch 0 taken 89 times.
✓ Branch 1 taken 38 times.
127 if(s_version < 7)
3910
1/2
✓ Branch 0 taken 89 times.
✗ Branch 1 not taken.
89 set_qr(qr_OLD_STRING_EDITOR_MARGINS,true);
3911
1/2
✓ Branch 0 taken 127 times.
✗ Branch 1 not taken.
127 init_msgstrings(0,msg_strings_size);
3912
3913 127 int32_t string_length=(s_version<2)?73:145;
3914
3915
2/2
✓ Branch 0 taken 27035 times.
✓ Branch 1 taken 127 times.
27162 for(int32_t i=0; i<temp_msg_count; i++)
3916 {
3917
1/2
✓ Branch 0 taken 27035 times.
✗ Branch 1 not taken.
27035 init_msgstr(&tempMsgString);
3918 27035 tempMsgString.listpos = i;
3919
2/2
✓ Branch 0 taken 896 times.
✓ Branch 1 taken 26139 times.
27035 if(s_version > 8)
3920 {
3921
2/4
✓ Branch 0 taken 896 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 896 times.
✗ Branch 3 not taken.
896 if(!p_igetl(&string_length,f))
3922 {
3923 return qe_invalid;
3924 }
3925 896 }
3926
3927
2/4
✓ Branch 0 taken 27035 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 27035 times.
27035 if (string_length < 0 || string_length > 8193)
3928 {
3929 return qe_invalid;
3930 }
3931
3932
2/2
✓ Branch 0 taken 26897 times.
✓ Branch 1 taken 138 times.
27035 if (string_length > 0)
3933 {
3934
2/4
✓ Branch 0 taken 26897 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 26897 times.
✗ Branch 3 not taken.
26897 if (!pfread(buf, string_length, f))
3935 {
3936 return qe_invalid;
3937 }
3938 26897 }
3939 else
3940 {
3941 138 buf[0] = 0;
3942 }
3943
3944
2/4
✓ Branch 0 taken 27035 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 27035 times.
✗ Branch 3 not taken.
27035 if(!p_igetw(&tempMsgString.nextstring,f))
3945 {
3946 return qe_invalid;
3947 }
3948
3949
2/2
✓ Branch 0 taken 19101 times.
✓ Branch 1 taken 7934 times.
27035 if(s_version<2)
3950 {
3951 19101 buf[72] = '\0';
3952
1/2
✓ Branch 0 taken 19101 times.
✗ Branch 1 not taken.
19101 tempMsgString.s = buf;
3953 19101 }
3954 else
3955 {
3956 // June 2008: A bug corrupted the last 4 chars of a string.
3957 // Discard these.
3958
1/2
✓ Branch 0 taken 7934 times.
✗ Branch 1 not taken.
7934 if(s_version<3)
3959 {
3960 for(int32_t j=140; j<144; j++)
3961 {
3962 buf[j] = '\0';
3963 }
3964 }
3965
1/2
✓ Branch 0 taken 7934 times.
✗ Branch 1 not taken.
7934 if(string_length > 8192) string_length = 8192;
3966 7934 buf[string_length]='\0'; //Force-terminate
3967
1/2
✓ Branch 0 taken 7934 times.
✗ Branch 1 not taken.
7934 tempMsgString.s = buf;
3968
3969
2/2
✓ Branch 0 taken 896 times.
✓ Branch 1 taken 7038 times.
7934 if ( s_version >= 6 )
3970 {
3971
2/4
✓ Branch 0 taken 896 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 896 times.
✗ Branch 3 not taken.
896 if(!p_igetl(&tempMsgString.tile,f))
3972 {
3973 return qe_invalid;
3974 }
3975 896 }
3976 else
3977 {
3978
2/4
✓ Branch 0 taken 7038 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7038 times.
✗ Branch 3 not taken.
7038 if(!p_igetw(&tempMsgString.tile,f))
3979 {
3980 return qe_invalid;
3981 }
3982 }
3983
3984
2/4
✓ Branch 0 taken 7934 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7934 times.
✗ Branch 3 not taken.
7934 if(!p_getc(&tempMsgString.cset,f))
3985 {
3986 return qe_invalid;
3987 }
3988
3989 byte dummy_char;
3990
3991
2/4
✓ Branch 0 taken 7934 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7934 times.
✗ Branch 3 not taken.
7934 if(!p_getc(&dummy_char,f)) // trans is stored as a char...
3992 {
3993 return qe_invalid;
3994 }
3995
3996 7934 tempMsgString.trans=dummy_char!=0;
3997
3998
2/4
✓ Branch 0 taken 7934 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7934 times.
✗ Branch 3 not taken.
7934 if(!p_getc(&tempMsgString.font,f))
3999 {
4000 return qe_invalid;
4001 }
4002
4003
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7934 times.
7934 if(s_version < 5)
4004 {
4005 if(!p_getc(&tempMsgString.y,f))
4006 {
4007 return qe_invalid;
4008 }
4009 }
4010 else
4011 {
4012
2/4
✓ Branch 0 taken 7934 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7934 times.
✗ Branch 3 not taken.
7934 if(!p_igetw(&tempMsgString.x,f))
4013 {
4014 return qe_invalid;
4015 }
4016
4017
2/4
✓ Branch 0 taken 7934 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7934 times.
✗ Branch 3 not taken.
7934 if(!p_igetw(&tempMsgString.y,f))
4018 {
4019 return qe_invalid;
4020 }
4021
4022
2/4
✓ Branch 0 taken 7934 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7934 times.
✗ Branch 3 not taken.
7934 if(!p_igetw(&tempMsgString.w,f))
4023 {
4024 return qe_invalid;
4025 }
4026
4027
2/4
✓ Branch 0 taken 7934 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7934 times.
✗ Branch 3 not taken.
7934 if(!p_igetw(&tempMsgString.h,f))
4028 {
4029 return qe_invalid;
4030 }
4031
4032
2/4
✓ Branch 0 taken 7934 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7934 times.
✗ Branch 3 not taken.
7934 if(!p_getc(&tempMsgString.hspace,f))
4033 {
4034 return qe_invalid;
4035 }
4036
4037
2/4
✓ Branch 0 taken 7934 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7934 times.
✗ Branch 3 not taken.
7934 if(!p_getc(&tempMsgString.vspace,f))
4038 {
4039 return qe_invalid;
4040 }
4041
4042
2/4
✓ Branch 0 taken 7934 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7934 times.
✗ Branch 3 not taken.
7934 if(!p_getc(&tempMsgString.stringflags,f))
4043 {
4044 return qe_invalid;
4045 }
4046 }
4047
4048
2/2
✓ Branch 0 taken 7038 times.
✓ Branch 1 taken 896 times.
7934 if(s_version >= 7)
4049 {
4050
2/2
✓ Branch 0 taken 896 times.
✓ Branch 1 taken 3584 times.
4480 for(int32_t q = 0; q < 4; ++q)
4051 {
4052
2/4
✓ Branch 0 taken 3584 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3584 times.
✗ Branch 3 not taken.
3584 if(!p_getc(&tempMsgString.margins[q],f))
4053 {
4054 return qe_invalid;
4055 }
4056 3584 }
4057
4058
2/4
✓ Branch 0 taken 896 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 896 times.
✗ Branch 3 not taken.
896 if(!p_igetl(&tempMsgString.portrait_tile,f))
4059 {
4060 return qe_invalid;
4061 }
4062
4063
2/4
✓ Branch 0 taken 896 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 896 times.
✗ Branch 3 not taken.
896 if(!p_getc(&tempMsgString.portrait_cset,f))
4064 {
4065 return qe_invalid;
4066 }
4067
4068
2/4
✓ Branch 0 taken 896 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 896 times.
✗ Branch 3 not taken.
896 if(!p_getc(&tempMsgString.portrait_x,f))
4069 {
4070 return qe_invalid;
4071 }
4072
4073
2/4
✓ Branch 0 taken 896 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 896 times.
✗ Branch 3 not taken.
896 if(!p_getc(&tempMsgString.portrait_y,f))
4074 {
4075 return qe_invalid;
4076 }
4077
4078
2/4
✓ Branch 0 taken 896 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 896 times.
✗ Branch 3 not taken.
896 if(!p_getc(&tempMsgString.portrait_tw,f))
4079 {
4080 return qe_invalid;
4081 }
4082
4083
2/4
✓ Branch 0 taken 896 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 896 times.
✗ Branch 3 not taken.
896 if(!p_getc(&tempMsgString.portrait_th,f))
4084 {
4085 return qe_invalid;
4086 }
4087 896 }
4088
4089
2/2
✓ Branch 0 taken 896 times.
✓ Branch 1 taken 7038 times.
7934 if(s_version >= 8)
4090 {
4091
2/4
✓ Branch 0 taken 896 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 896 times.
✗ Branch 3 not taken.
896 if(!p_getc(&tempMsgString.shadow_type,f))
4092 {
4093 return qe_invalid;
4094 }
4095
4096
2/4
✓ Branch 0 taken 896 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 896 times.
✗ Branch 3 not taken.
896 if(!p_getc(&tempMsgString.shadow_color,f))
4097 {
4098 return qe_invalid;
4099 }
4100 896 }
4101
4102
2/2
✓ Branch 0 taken 779 times.
✓ Branch 1 taken 7155 times.
7934 if(s_version >= 10)
4103 {
4104
2/4
✓ Branch 0 taken 779 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 779 times.
✗ Branch 3 not taken.
779 if(!p_getc(&tempMsgString.drawlayer,f))
4105 {
4106 return qe_invalid;
4107 }
4108 779 }
4109
4110
2/4
✓ Branch 0 taken 7934 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7934 times.
✗ Branch 3 not taken.
7934 if(!p_getc(&tempMsgString.sfx,f))
4111 {
4112 return qe_invalid;
4113 }
4114
4115
1/2
✓ Branch 0 taken 7934 times.
✗ Branch 1 not taken.
7934 if(s_version>3)
4116 {
4117
2/4
✓ Branch 0 taken 7934 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7934 times.
✗ Branch 3 not taken.
7934 if(!p_igetw(&tempMsgString.listpos,f))
4118 {
4119 return qe_invalid;
4120 }
4121 7934 }
4122 }
4123
4124
1/2
✓ Branch 0 taken 27035 times.
✗ Branch 1 not taken.
27035 MsgStrings[i].copyAll(tempMsgString);
4125 27035 }
4126 }
4127
4128
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 131 times.
131 if (!should_skip)
4129 131 msg_count=temp_msg_count;
4130
4131 131 return 0;
4132 131 }
4133
4134 131 int32_t readdoorcombosets(PACKFILE *f, zquestheader *Header)
4135 {
4136
2/2
✓ Branch 0 taken 127 times.
✓ Branch 1 taken 4 times.
131 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_doors);
4137
4138
2/4
✓ Branch 0 taken 127 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
131 if((Header->zelda_version < 0x192)||
4139
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 127 times.
127 ((Header->zelda_version == 0x192)&&(Header->build<158)))
4140 {
4141 4 return 0;
4142 }
4143
4144 127 word temp_door_combo_set_count=0;
4145 DoorComboSet tempDoorComboSet;
4146 word dummy_word;
4147 int32_t dummy_long;
4148 byte padding;
4149 127 int32_t s_version = 0;
4150
4151
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 127 times.
127 if (!should_skip)
4152
2/2
✓ Branch 0 taken 32512 times.
✓ Branch 1 taken 127 times.
32639 for(int32_t i=0; i<MAXDOORCOMBOSETS; i++)
4153 {
4154 32512 memset(DoorComboSets+i, 0, sizeof(DoorComboSet));
4155 32639 }
4156
4157
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 127 times.
127 if(Header->zelda_version > 0x192)
4158 {
4159 //section version info
4160
1/2
✓ Branch 0 taken 127 times.
✗ Branch 1 not taken.
127 if(!p_igetw(&s_version,f))
4161 {
4162 return qe_invalid;
4163 }
4164
4165 127 FFCore.quest_format[vDoors] = s_version;
4166
4167 //al_trace("Door combo sets version %d\n", dummy_word);
4168
1/2
✓ Branch 0 taken 127 times.
✗ Branch 1 not taken.
127 if(!p_igetw(&dummy_word,f))
4169 {
4170 return qe_invalid;
4171 }
4172
4173 //section size
4174
1/2
✓ Branch 0 taken 127 times.
✗ Branch 1 not taken.
127 if(!p_igetl(&dummy_long,f))
4175 {
4176 return qe_invalid;
4177 }
4178 127 }
4179
4180 //finally... section data
4181
1/2
✓ Branch 0 taken 127 times.
✗ Branch 1 not taken.
127 if(!p_igetw(&temp_door_combo_set_count,f))
4182 {
4183 return qe_invalid;
4184 }
4185
4186
2/4
✓ Branch 0 taken 127 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 127 times.
127 if (!(temp_door_combo_set_count >= 0 && temp_door_combo_set_count <= MAXDOORCOMBOSETS))
4187 {
4188 return qe_invalid;
4189 }
4190
4191
2/2
✓ Branch 0 taken 1015 times.
✓ Branch 1 taken 127 times.
1142 for(int32_t i=0; i<temp_door_combo_set_count; i++)
4192 {
4193 1015 memset(&tempDoorComboSet, 0, sizeof(DoorComboSet));
4194
4195 //name
4196
1/2
✓ Branch 0 taken 1015 times.
✗ Branch 1 not taken.
1015 if(!pfread(&tempDoorComboSet.name,sizeof(tempDoorComboSet.name),f))
4197 {
4198 return qe_invalid;
4199 }
4200
4201
1/2
✓ Branch 0 taken 1015 times.
✗ Branch 1 not taken.
1015 if(Header->zelda_version < 0x193)
4202 {
4203 if(!p_getc(&padding,f))
4204 {
4205 return qe_invalid;
4206 }
4207 }
4208
4209 //up door
4210
2/2
✓ Branch 0 taken 9135 times.
✓ Branch 1 taken 1015 times.
10150 for(int32_t j=0; j<9; j++)
4211 {
4212
2/2
✓ Branch 0 taken 36540 times.
✓ Branch 1 taken 9135 times.
45675 for(int32_t k=0; k<4; k++)
4213 {
4214
1/2
✓ Branch 0 taken 36540 times.
✗ Branch 1 not taken.
36540 if(!p_igetw(&tempDoorComboSet.doorcombo_u[j][k],f))
4215 {
4216 return qe_invalid;
4217 }
4218 36540 }
4219 9135 }
4220
4221
2/2
✓ Branch 0 taken 9135 times.
✓ Branch 1 taken 1015 times.
10150 for(int32_t j=0; j<9; j++)
4222 {
4223
2/2
✓ Branch 0 taken 36540 times.
✓ Branch 1 taken 9135 times.
45675 for(int32_t k=0; k<4; k++)
4224 {
4225
1/2
✓ Branch 0 taken 36540 times.
✗ Branch 1 not taken.
36540 if(!p_getc(&tempDoorComboSet.doorcset_u[j][k],f))
4226 {
4227 return qe_invalid;
4228 }
4229 36540 }
4230 9135 }
4231
4232 //down door
4233
2/2
✓ Branch 0 taken 9135 times.
✓ Branch 1 taken 1015 times.
10150 for(int32_t j=0; j<9; j++)
4234 {
4235
2/2
✓ Branch 0 taken 36540 times.
✓ Branch 1 taken 9135 times.
45675 for(int32_t k=0; k<4; k++)
4236 {
4237
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 36540 times.
36540 if(!p_igetw(&tempDoorComboSet.doorcombo_d[j][k],f))
4238 {
4239 return qe_invalid;
4240 }
4241 36540 }
4242 9135 }
4243
4244
2/2
✓ Branch 0 taken 9135 times.
✓ Branch 1 taken 1015 times.
10150 for(int32_t j=0; j<9; j++)
4245 {
4246
2/2
✓ Branch 0 taken 36540 times.
✓ Branch 1 taken 9135 times.
45675 for(int32_t k=0; k<4; k++)
4247 {
4248
1/2
✓ Branch 0 taken 36540 times.
✗ Branch 1 not taken.
36540 if(!p_getc(&tempDoorComboSet.doorcset_d[j][k],f))
4249 {
4250 return qe_invalid;
4251 }
4252 36540 }
4253 9135 }
4254
4255 //left door
4256
2/2
✓ Branch 0 taken 9135 times.
✓ Branch 1 taken 1015 times.
10150 for(int32_t j=0; j<9; j++)
4257 {
4258
2/2
✓ Branch 0 taken 54810 times.
✓ Branch 1 taken 9135 times.
63945 for(int32_t k=0; k<6; k++)
4259 {
4260
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 54810 times.
54810 if(!p_igetw(&tempDoorComboSet.doorcombo_l[j][k],f))
4261 {
4262 return qe_invalid;
4263 }
4264 54810 }
4265 9135 }
4266
4267
2/2
✓ Branch 0 taken 9135 times.
✓ Branch 1 taken 1015 times.
10150 for(int32_t j=0; j<9; j++)
4268 {
4269
2/2
✓ Branch 0 taken 54810 times.
✓ Branch 1 taken 9135 times.
63945 for(int32_t k=0; k<6; k++)
4270 {
4271
1/2
✓ Branch 0 taken 54810 times.
✗ Branch 1 not taken.
54810 if(!p_getc(&tempDoorComboSet.doorcset_l[j][k],f))
4272 {
4273 return qe_invalid;
4274 }
4275 54810 }
4276 9135 }
4277
4278 //right door
4279
2/2
✓ Branch 0 taken 9135 times.
✓ Branch 1 taken 1015 times.
10150 for(int32_t j=0; j<9; j++)
4280 {
4281
2/2
✓ Branch 0 taken 54810 times.
✓ Branch 1 taken 9135 times.
63945 for(int32_t k=0; k<6; k++)
4282 {
4283
1/2
✓ Branch 0 taken 54810 times.
✗ Branch 1 not taken.
54810 if(!p_igetw(&tempDoorComboSet.doorcombo_r[j][k],f))
4284 {
4285 return qe_invalid;
4286 }
4287 54810 }
4288 9135 }
4289
4290
2/2
✓ Branch 0 taken 9135 times.
✓ Branch 1 taken 1015 times.
10150 for(int32_t j=0; j<9; j++)
4291 {
4292
2/2
✓ Branch 0 taken 54810 times.
✓ Branch 1 taken 9135 times.
63945 for(int32_t k=0; k<6; k++)
4293 {
4294
1/2
✓ Branch 0 taken 54810 times.
✗ Branch 1 not taken.
54810 if(!p_getc(&tempDoorComboSet.doorcset_r[j][k],f))
4295 {
4296 return qe_invalid;
4297 }
4298 54810 }
4299 9135 }
4300
4301 //up bomb rubble
4302
2/2
✓ Branch 0 taken 2030 times.
✓ Branch 1 taken 1015 times.
3045 for(int32_t j=0; j<2; j++)
4303 {
4304
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2030 times.
2030 if(!p_igetw(&tempDoorComboSet.bombdoorcombo_u[j],f))
4305 {
4306 return qe_invalid;
4307 }
4308 2030 }
4309
4310
2/2
✓ Branch 0 taken 2030 times.
✓ Branch 1 taken 1015 times.
3045 for(int32_t j=0; j<2; j++)
4311 {
4312
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2030 times.
2030 if(!p_getc(&tempDoorComboSet.bombdoorcset_u[j],f))
4313 {
4314 return qe_invalid;
4315 }
4316 2030 }
4317
4318 //down bomb rubble
4319
2/2
✓ Branch 0 taken 2030 times.
✓ Branch 1 taken 1015 times.
3045 for(int32_t j=0; j<2; j++)
4320 {
4321
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2030 times.
2030 if(!p_igetw(&tempDoorComboSet.bombdoorcombo_d[j],f))
4322 {
4323 return qe_invalid;
4324 }
4325 2030 }
4326
4327
2/2
✓ Branch 0 taken 2030 times.
✓ Branch 1 taken 1015 times.
3045 for(int32_t j=0; j<2; j++)
4328 {
4329
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2030 times.
2030 if(!p_getc(&tempDoorComboSet.bombdoorcset_d[j],f))
4330 {
4331 return qe_invalid;
4332 }
4333 2030 }
4334
4335 //left bomb rubble
4336
2/2
✓ Branch 0 taken 3045 times.
✓ Branch 1 taken 1015 times.
4060 for(int32_t j=0; j<3; j++)
4337 {
4338
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3045 times.
3045 if(!p_igetw(&tempDoorComboSet.bombdoorcombo_l[j],f))
4339 {
4340 return qe_invalid;
4341 }
4342 3045 }
4343
4344
2/2
✓ Branch 0 taken 3045 times.
✓ Branch 1 taken 1015 times.
4060 for(int32_t j=0; j<3; j++)
4345 {
4346
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3045 times.
3045 if(!p_getc(&tempDoorComboSet.bombdoorcset_l[j],f))
4347 {
4348 return qe_invalid;
4349 }
4350 3045 }
4351
4352
1/2
✓ Branch 0 taken 1015 times.
✗ Branch 1 not taken.
1015 if(Header->zelda_version < 0x193)
4353 {
4354 if(!p_getc(&padding,f))
4355 {
4356 return qe_invalid;
4357 }
4358
4359 }
4360
4361 //right bomb rubble
4362
2/2
✓ Branch 0 taken 3045 times.
✓ Branch 1 taken 1015 times.
4060 for(int32_t j=0; j<3; j++)
4363 {
4364
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3045 times.
3045 if(!p_igetw(&tempDoorComboSet.bombdoorcombo_r[j],f))
4365 {
4366 return qe_invalid;
4367 }
4368 3045 }
4369
4370
2/2
✓ Branch 0 taken 3045 times.
✓ Branch 1 taken 1015 times.
4060 for(int32_t j=0; j<3; j++)
4371 {
4372
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3045 times.
3045 if(!p_getc(&tempDoorComboSet.bombdoorcset_r[j],f))
4373 {
4374 return qe_invalid;
4375 }
4376 3045 }
4377
4378
1/2
✓ Branch 0 taken 1015 times.
✗ Branch 1 not taken.
1015 if(Header->zelda_version < 0x193)
4379 {
4380 if(!p_getc(&padding,f))
4381 {
4382 return qe_invalid;
4383 }
4384 }
4385
4386 //walkthrough stuff
4387
2/2
✓ Branch 0 taken 4060 times.
✓ Branch 1 taken 1015 times.
5075 for(int32_t j=0; j<4; j++)
4388 {
4389
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4060 times.
4060 if(!p_igetw(&tempDoorComboSet.walkthroughcombo[j],f))
4390 {
4391 return qe_invalid;
4392 }
4393 4060 }
4394
4395
2/2
✓ Branch 0 taken 4060 times.
✓ Branch 1 taken 1015 times.
5075 for(int32_t j=0; j<4; j++)
4396 {
4397
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4060 times.
4060 if(!p_getc(&tempDoorComboSet.walkthroughcset[j],f))
4398 {
4399 return qe_invalid;
4400 }
4401 4060 }
4402
4403 //flags
4404
2/2
✓ Branch 0 taken 2030 times.
✓ Branch 1 taken 1015 times.
3045 for(int32_t j=0; j<2; j++)
4405 {
4406
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2030 times.
2030 if(!p_getc(&tempDoorComboSet.flags[j],f))
4407 {
4408 return qe_invalid;
4409 }
4410 2030 }
4411
4412
1/2
✓ Branch 0 taken 1015 times.
✗ Branch 1 not taken.
1015 if(Header->zelda_version < 0x193)
4413 {
4414 if(!pfread(&tempDoorComboSet.expansion,sizeof(tempDoorComboSet.expansion),f))
4415 {
4416 return qe_invalid;
4417 }
4418 }
4419
4420
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1015 times.
1015 if (!should_skip)
4421 1015 memcpy(&DoorComboSets[i], &tempDoorComboSet, sizeof(tempDoorComboSet));
4422 1015 }
4423
4424
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 127 times.
127 if (!should_skip)
4425 127 door_combo_set_count=temp_door_combo_set_count;
4426
4427 127 return 0;
4428 131 }
4429
4430 int32_t count_dmaps()
4431 {
4432 int32_t i=MAXDMAPS-1;
4433 bool found=false;
4434
4435 while(i>=0 && !found)
4436 {
4437 if((DMaps[i].map!=0)||(DMaps[i].level!=0)||(DMaps[i].xoff!=0)||
4438 (DMaps[i].compass!=0)||(DMaps[i].color!=0)||(DMaps[i].midi!=0)||
4439 (DMaps[i].cont!=0)||(DMaps[i].type!=0))
4440 found=true;
4441
4442 for(int32_t j=0; j<8; j++)
4443 {
4444 if(DMaps[i].grid[j]!=0)
4445
4446 found=true;
4447 }
4448
4449 if((DMaps[i].name[0]!=0)||(DMaps[i].title[0]!=0)||
4450 (DMaps[i].intro[0]!=0)||(DMaps[i].tmusic[0]!=0))
4451 found=true;
4452
4453 if((DMaps[i].minimap_1_tile!=0)||(DMaps[i].minimap_2_tile!=0)||
4454 (DMaps[i].largemap_1_tile!=0)||(DMaps[i].largemap_2_tile!=0)||
4455 (DMaps[i].minimap_1_cset!=0)||(DMaps[i].minimap_2_cset!=0)||
4456 (DMaps[i].largemap_1_cset!=0)||(DMaps[i].largemap_2_cset!=0))
4457 found=true;
4458
4459 if(!found)
4460 {
4461 i--;
4462 }
4463 }
4464
4465 return i+1;
4466 }
4467
4468
4469 int32_t count_shops(miscQdata *Misc)
4470 {
4471 int32_t i=NUM_SHOPS-1,j;
4472 bool found=false;
4473
4474 while(i>=0 && !found)
4475 {
4476 j=2;
4477
4478 while(j>=0 && !found)
4479 {
4480 if((Misc->shop[i].hasitem[j]!=0)||(Misc->shop[i].price[j]!=0))
4481 {
4482 found=true;
4483 }
4484 else
4485 {
4486 j--;
4487 }
4488 }
4489
4490 if(Misc->shop[i].name[0]!=0)
4491 {
4492 found=true;
4493 }
4494
4495 if(!found)
4496 {
4497 i--;
4498 }
4499 }
4500
4501 return i+1;
4502 }
4503
4504 int32_t count_infos(miscQdata *Misc)
4505 {
4506 int32_t i=255,j;
4507 bool found=false;
4508
4509 while(i>=0 && !found)
4510 {
4511 j=2;
4512
4513 while(j>=0 && !found)
4514 {
4515 if((Misc->info[i].str[j]!=0)||(Misc->info[i].price[j]!=0))
4516 {
4517 found=true;
4518 }
4519 else
4520 {
4521 j--;
4522 }
4523 }
4524
4525 if(Misc->info[i].name[0]!=0)
4526 {
4527 found=true;
4528 }
4529
4530 if(!found)
4531 {
4532 i--;
4533 }
4534 }
4535
4536 return i+1;
4537 }
4538
4539 int32_t count_warprings(miscQdata *Misc)
4540 {
4541 int32_t i=15,j;
4542 bool found=false;
4543
4544 while(i>=0 && !found)
4545 {
4546 j=7;
4547
4548 while(j>=0 && !found)
4549 {
4550 if((Misc->warp[i].dmap[j]!=0)||(Misc->warp[i].scr[j]!=0))
4551 {
4552 found=true;
4553 }
4554 else
4555 {
4556 j--;
4557 }
4558 }
4559
4560 if(!found)
4561 {
4562 i--;
4563 }
4564 }
4565
4566 return i+1;
4567 }
4568
4569 int32_t count_palcycles(miscQdata *Misc)
4570 {
4571 int32_t i=255,j;
4572 bool found=false;
4573
4574 while(i>=0 && !found)
4575 {
4576 j=2;
4577
4578 while(j>=0 && !found)
4579 {
4580 if(Misc->cycles[i][j].count!=0)
4581 {
4582 found=true;
4583 }
4584 else
4585 {
4586 j--;
4587 }
4588 }
4589
4590 if(!found)
4591 {
4592 i--;
4593 }
4594 }
4595
4596 return i+1;
4597 }
4598
4599 265259 void clear_screen(mapscr *temp_scr)
4600 {
4601 265259 temp_scr->zero_memory();
4602 265259 }
4603
4604 131 int32_t readdmaps(PACKFILE *f, zquestheader *Header, word, word, word start_dmap, word max_dmaps)
4605 {
4606
2/2
✓ Branch 0 taken 127 times.
✓ Branch 1 taken 4 times.
131 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_dmaps);
4607
4608 131 word dmapstoread=0;
4609 131 dmap tempDMap;
4610
4611 int32_t dummy;
4612 131 word s_version=0, s_cversion=0;
4613 byte padding;
4614
4615 char legacy_title[22];
4616
4617
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 131 times.
131 if (!should_skip)
4618
2/2
✓ Branch 0 taken 67072 times.
✓ Branch 1 taken 131 times.
67203 for(int32_t i=0; i<max_dmaps; i++)
4619 {
4620
1/2
✓ Branch 0 taken 67072 times.
✗ Branch 1 not taken.
67072 DMaps[start_dmap + i].clear();
4621 67072 sprintf(legacy_title," ");
4622 67072 sprintf(DMaps[start_dmap+i].intro," ");
4623 67072 DMaps[start_dmap+i].type |= dmCAVE;
4624 67203 }
4625
4626
3/4
✓ Branch 0 taken 131 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 127 times.
✓ Branch 3 taken 4 times.
131 if(!Header || Header->zelda_version > 0x192)
4627 {
4628 //section version info
4629
2/4
✓ Branch 0 taken 127 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 127 times.
✗ Branch 3 not taken.
127 if(!p_igetw(&s_version,f))
4630 {
4631 return qe_invalid;
4632 }
4633
4634 127 FFCore.quest_format[vDMaps] = s_version;
4635
4636 //al_trace("DMaps version %d\n", s_version);
4637
4638
2/4
✓ Branch 0 taken 127 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 127 times.
✗ Branch 3 not taken.
127 if(!p_igetw(&s_cversion,f))
4639 {
4640 return qe_invalid;
4641 }
4642
4643 //section size
4644
2/4
✓ Branch 0 taken 127 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 127 times.
✗ Branch 3 not taken.
127 if(!p_igetl(&dummy,f))
4645 {
4646 return qe_invalid;
4647 }
4648
4649 //finally... section data
4650
2/4
✓ Branch 0 taken 127 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 127 times.
✗ Branch 3 not taken.
127 if(!p_igetw(&dmapstoread,f))
4651 {
4652 return qe_invalid;
4653 }
4654 127 }
4655 else
4656 {
4657
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4 if((Header->zelda_version < 0x192)||
4658 ((Header->zelda_version == 0x192)&&(Header->build<5)))
4659 {
4660 4 dmapstoread=32;
4661 4 }
4662 else if(s_version <= 4)
4663 {
4664 dmapstoread=OLDMAXDMAPS;
4665 }
4666 else
4667 {
4668 dmapstoread=MAXDMAPS;
4669 }
4670 }
4671
4672
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 115 times.
131 dmapstoread=zc_min(dmapstoread, max_dmaps);
4673
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 115 times.
131 dmapstoread=zc_min(dmapstoread, MAXDMAPS-start_dmap);
4674
4675
2/2
✓ Branch 0 taken 62080 times.
✓ Branch 1 taken 131 times.
62211 for(int32_t i=start_dmap; i<dmapstoread+start_dmap; i++)
4676 {
4677
1/2
✓ Branch 0 taken 62080 times.
✗ Branch 1 not taken.
62080 tempDMap.clear();
4678 62080 sprintf(legacy_title," ");
4679 62080 sprintf(tempDMap.intro," ");
4680
4681
2/4
✓ Branch 0 taken 62080 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 62080 times.
✗ Branch 3 not taken.
62080 if(!p_getc(&tempDMap.map,f))
4682 {
4683 return qe_invalid;
4684 }
4685
4686
2/2
✓ Branch 0 taken 3200 times.
✓ Branch 1 taken 58880 times.
62080 if(s_version <= 4)
4687 {
4688 byte tempbyte;
4689
4690
2/4
✓ Branch 0 taken 3200 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3200 times.
✗ Branch 3 not taken.
3200 if(!p_getc(&tempbyte,f))
4691 {
4692 return qe_invalid;
4693 }
4694
4695 3200 tempDMap.level=(word)tempbyte;
4696 3200 }
4697 else
4698 {
4699
2/4
✓ Branch 0 taken 58880 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 58880 times.
✗ Branch 3 not taken.
58880 if(!p_igetw(&tempDMap.level,f))
4700 {
4701 return qe_invalid;
4702 }
4703 }
4704
4705
2/4
✓ Branch 0 taken 62080 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 62080 times.
✗ Branch 3 not taken.
62080 if(!p_getc(&tempDMap.xoff,f))
4706 {
4707 return qe_invalid;
4708 }
4709
4710
2/4
✓ Branch 0 taken 62080 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 62080 times.
✗ Branch 3 not taken.
62080 if(!p_getc(&tempDMap.compass,f))
4711 {
4712 return qe_invalid;
4713 }
4714
4715
2/2
✓ Branch 0 taken 58880 times.
✓ Branch 1 taken 3200 times.
62080 if(s_version > 8) // February 2009
4716 {
4717
2/4
✓ Branch 0 taken 58880 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 58880 times.
✗ Branch 3 not taken.
58880 if(!p_igetw(&tempDMap.color,f))
4718 {
4719 return qe_invalid;
4720 }
4721 58880 }
4722 else
4723 {
4724 byte tempbyte;
4725
4726
2/4
✓ Branch 0 taken 3200 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3200 times.
✗ Branch 3 not taken.
3200 if(!p_getc(&tempbyte,f))
4727 {
4728 return qe_invalid;
4729 }
4730
4731 3200 tempDMap.color = (word)tempbyte;
4732 }
4733
4734
2/4
✓ Branch 0 taken 62080 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 62080 times.
✗ Branch 3 not taken.
62080 if(!p_getc(&tempDMap.midi,f))
4735 {
4736 return qe_invalid;
4737 }
4738
4739
2/4
✓ Branch 0 taken 62080 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 62080 times.
✗ Branch 3 not taken.
62080 if(!p_getc(&tempDMap.cont,f))
4740 {
4741 return qe_invalid;
4742 }
4743
4744
2/4
✓ Branch 0 taken 62080 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 62080 times.
✗ Branch 3 not taken.
62080 if(!p_getc(&tempDMap.type,f))
4745 {
4746 return qe_invalid;
4747 }
4748
4749
4/4
✓ Branch 0 taken 834 times.
✓ Branch 1 taken 61246 times.
✓ Branch 2 taken 822 times.
✓ Branch 3 taken 12 times.
62914 if((tempDMap.type & dmfTYPE) == dmOVERW &&
4750
1/2
✓ Branch 0 taken 834 times.
✗ Branch 1 not taken.
834 (!Header || Header->zelda_version >= 0x210)) // Not sure exactly when this changed
4751 822 tempDMap.xoff = 0;
4752
4753
2/2
✓ Branch 0 taken 62080 times.
✓ Branch 1 taken 496640 times.
558720 for(int32_t j=0; j<8; j++)
4754 {
4755
2/4
✓ Branch 0 taken 496640 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 496640 times.
✗ Branch 3 not taken.
496640 if(!p_getc(&tempDMap.grid[j],f))
4756 {
4757 return qe_invalid;
4758 }
4759 496640 }
4760
4761
4/6
✓ Branch 0 taken 62080 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 61952 times.
✓ Branch 3 taken 128 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 61952 times.
62080 if(Header && ((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<41))))
4762 {
4763
3/4
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 90 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 38 times.
128 if(tempDMap.level>0&&tempDMap.level<10)
4764 {
4765 38 sprintf(legacy_title,"LEVEL-%d ", tempDMap.level);
4766 38 }
4767
1/2
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
128 tempDMap.title.assign(legacy_title);
4768
4769
3/4
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 124 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
128 if(i==0 && Header->zelda_version <= 0x190)
4770 {
4771 4 tempDMap.cont-=tempDMap.xoff;
4772 4 tempDMap.compass-=tempDMap.xoff;
4773 4 }
4774
4775 //forgotten -DD
4776
2/2
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 90 times.
128 if(tempDMap.level==0)
4777 {
4778 90 tempDMap.flags=dmfCAVES|dmf3STAIR|dmfWHIRLWIND|dmfGUYCAVES;
4779 90 }
4780 128 }
4781 else
4782 {
4783
2/4
✓ Branch 0 taken 61952 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 61952 times.
✗ Branch 3 not taken.
61952 if(!p_getstr(tempDMap.name,sizeof(DMaps[0].name) - 1,f))
4784 {
4785 return qe_invalid;
4786 }
4787
4788
2/2
✓ Branch 0 taken 47104 times.
✓ Branch 1 taken 14848 times.
61952 if(s_version<20)
4789 {
4790
2/4
✓ Branch 0 taken 47104 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 47104 times.
✗ Branch 3 not taken.
47104 if (!p_getstr(legacy_title, sizeof(legacy_title) - 1, f))
4791 {
4792 return qe_invalid;
4793 }
4794
1/2
✓ Branch 0 taken 47104 times.
✗ Branch 1 not taken.
47104 tempDMap.title.assign(legacy_title);
4795 47104 }
4796 else
4797 {
4798 14848 std::string tmptitle;
4799
2/4
✓ Branch 0 taken 14848 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 14848 times.
✗ Branch 3 not taken.
14848 if (!p_getwstr(&tmptitle, f))
4800 {
4801 return qe_invalid;
4802 }
4803
1/2
✓ Branch 0 taken 14848 times.
✗ Branch 1 not taken.
14848 tempDMap.title.reserve(tmptitle.size());
4804
1/2
✓ Branch 0 taken 14848 times.
✗ Branch 1 not taken.
14848 tempDMap.title = tmptitle;
4805
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14848 times.
14848 }
4806
4807
2/4
✓ Branch 0 taken 61952 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 61952 times.
✗ Branch 3 not taken.
61952 if(!p_getstr(tempDMap.intro,sizeof(DMaps[0].intro)-1,f))
4808 {
4809 return qe_invalid;
4810 }
4811
4812
3/8
✓ Branch 0 taken 61952 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 61952 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 61952 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
61952 if(Header && ((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<152))))
4813 {
4814 if ((tempDMap.type & dmfTYPE) == dmOVERW) tempDMap.flags = dmfCAVES | dmf3STAIR | dmfWHIRLWIND | dmfGUYCAVES;
4815 DMaps[i] = tempDMap;
4816
4817 continue;
4818 }
4819
4820
2/4
✓ Branch 0 taken 61952 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 61952 times.
61952 if(Header && (Header->zelda_version < 0x193))
4821 {
4822 if(!p_getc(&padding,f))
4823 {
4824 return qe_invalid;
4825 }
4826 }
4827
2/2
✓ Branch 0 taken 19456 times.
✓ Branch 1 taken 42496 times.
61952 if ( s_version >= 11 )
4828 {
4829
2/4
✓ Branch 0 taken 19456 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 19456 times.
✗ Branch 3 not taken.
19456 if(!p_igetl(&tempDMap.minimap_1_tile,f))
4830 {
4831 return qe_invalid;
4832 }
4833 19456 }
4834 else
4835 {
4836
2/4
✓ Branch 0 taken 42496 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 42496 times.
✗ Branch 3 not taken.
42496 if(!p_igetw(&tempDMap.minimap_1_tile,f))
4837 {
4838 return qe_invalid;
4839 }
4840 }
4841
4842
2/4
✓ Branch 0 taken 61952 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 61952 times.
✗ Branch 3 not taken.
61952 if(!p_getc(&tempDMap.minimap_1_cset,f))
4843 {
4844 return qe_invalid;
4845 }
4846
4847
2/4
✓ Branch 0 taken 61952 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 61952 times.
61952 if(Header && (Header->zelda_version < 0x193))
4848 {
4849 if(!p_getc(&padding,f))
4850 {
4851 return qe_invalid;
4852 }
4853 }
4854
4855
2/2
✓ Branch 0 taken 19456 times.
✓ Branch 1 taken 42496 times.
61952 if ( s_version >= 11 )
4856 {
4857
2/4
✓ Branch 0 taken 19456 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 19456 times.
✗ Branch 3 not taken.
19456 if(!p_igetl(&tempDMap.minimap_2_tile,f))
4858 {
4859 return qe_invalid;
4860 }
4861 19456 }
4862 else
4863 {
4864
2/4
✓ Branch 0 taken 42496 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 42496 times.
✗ Branch 3 not taken.
42496 if(!p_igetw(&tempDMap.minimap_2_tile,f))
4865 {
4866 return qe_invalid;
4867 }
4868 }
4869
2/4
✓ Branch 0 taken 61952 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 61952 times.
✗ Branch 3 not taken.
61952 if(!p_getc(&tempDMap.minimap_2_cset,f))
4870 {
4871 return qe_invalid;
4872 }
4873
4874
2/4
✓ Branch 0 taken 61952 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 61952 times.
61952 if(Header && (Header->zelda_version < 0x193))
4875 {
4876 if(!p_getc(&padding,f))
4877 {
4878 return qe_invalid;
4879 }
4880 }
4881
4882
2/2
✓ Branch 0 taken 19456 times.
✓ Branch 1 taken 42496 times.
61952 if ( s_version >= 11 )
4883 {
4884
2/4
✓ Branch 0 taken 19456 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 19456 times.
19456 if(!p_igetl(&tempDMap.largemap_1_tile,f))
4885 {
4886 return qe_invalid;
4887 }
4888 19456 }
4889 else
4890 {
4891
2/4
✓ Branch 0 taken 42496 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 42496 times.
42496 if(!p_igetw(&tempDMap.largemap_1_tile,f))
4892 {
4893 return qe_invalid;
4894 }
4895 }
4896
4897
2/4
✓ Branch 0 taken 61952 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 61952 times.
✗ Branch 3 not taken.
61952 if(!p_getc(&tempDMap.largemap_1_cset,f))
4898 {
4899 return qe_invalid;
4900 }
4901
4902
2/4
✓ Branch 0 taken 61952 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 61952 times.
61952 if(Header && (Header->zelda_version < 0x193))
4903 {
4904
4905 if(!p_getc(&padding,f))
4906 {
4907 return qe_invalid;
4908 }
4909 }
4910
4911
2/2
✓ Branch 0 taken 19456 times.
✓ Branch 1 taken 42496 times.
61952 if ( s_version >= 11 )
4912 {
4913
2/4
✓ Branch 0 taken 19456 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 19456 times.
✗ Branch 3 not taken.
19456 if(!p_igetl(&tempDMap.largemap_2_tile,f))
4914 {
4915 return qe_invalid;
4916 }
4917 19456 }
4918 else
4919 {
4920
2/4
✓ Branch 0 taken 42496 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 42496 times.
✗ Branch 3 not taken.
42496 if(!p_igetw(&tempDMap.largemap_2_tile,f))
4921 {
4922 return qe_invalid;
4923 }
4924 }
4925
2/4
✓ Branch 0 taken 61952 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 61952 times.
✗ Branch 3 not taken.
61952 if(!p_getc(&tempDMap.largemap_2_cset,f))
4926 {
4927 return qe_invalid;
4928 }
4929
4930
2/4
✓ Branch 0 taken 61952 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 61952 times.
✗ Branch 3 not taken.
61952 if(!p_getstr(tempDMap.tmusic,sizeof(DMaps[0].tmusic)-1,f))
4931 {
4932 return qe_invalid;
4933 }
4934 }
4935
4936
2/2
✓ Branch 0 taken 58880 times.
✓ Branch 1 taken 3200 times.
62080 if(s_version>1)
4937 {
4938
2/4
✓ Branch 0 taken 58880 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 58880 times.
✗ Branch 3 not taken.
58880 if(!p_getc(&tempDMap.tmusictrack,f))
4939 {
4940 return qe_invalid;
4941 }
4942
4943
2/4
✓ Branch 0 taken 58880 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 58880 times.
✗ Branch 3 not taken.
58880 if(!p_getc(&tempDMap.active_subscreen,f))
4944 {
4945 return qe_invalid;
4946 }
4947
4948
2/4
✓ Branch 0 taken 58880 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 58880 times.
✗ Branch 3 not taken.
58880 if(!p_getc(&tempDMap.passive_subscreen,f))
4949 {
4950 return qe_invalid;
4951 }
4952 58880 }
4953
4954
2/2
✓ Branch 0 taken 58880 times.
✓ Branch 1 taken 3200 times.
62080 if(s_version>2)
4955 {
4956 byte di[32];
4957
4958
2/4
✓ Branch 0 taken 58880 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 58880 times.
✗ Branch 3 not taken.
58880 if(!pfread(&di, 32, f)) return qe_invalid;
4959
4960
2/2
✓ Branch 0 taken 15073280 times.
✓ Branch 1 taken 58880 times.
15132160 for(int32_t j=0; j<MAXITEMS; j++)
4961 {
4962
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 15073273 times.
15073280 if(di[j/8] & (1 << (j%8))) tempDMap.disableditems[j]=1;
4963 15073273 else tempDMap.disableditems[j]=0;
4964 15073280 }
4965 58880 }
4966
4967
2/2
✓ Branch 0 taken 58880 times.
✓ Branch 1 taken 3200 times.
62080 if(s_version >= 6)
4968 {
4969
2/4
✓ Branch 0 taken 58880 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 58880 times.
✗ Branch 3 not taken.
58880 if(!p_igetl(&tempDMap.flags,f))
4970 {
4971 return qe_invalid;
4972 }
4973 58880 }
4974
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3200 times.
3200 else if(s_version>3)
4975 {
4976 char temp;
4977
4978 if(!p_getc(&temp,f))
4979 {
4980 return qe_invalid;
4981 }
4982
4983 tempDMap.flags = temp;
4984 }
4985
3/8
✓ Branch 0 taken 816 times.
✓ Branch 1 taken 2384 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 816 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
3200 else if(tempDMap.level==0 && ((Header->zelda_version < 0x211) || ((Header->zelda_version == 0x211) && (Header->build<18))))
4986 {
4987 816 tempDMap.flags=dmfCAVES|dmf3STAIR|dmfWHIRLWIND|dmfGUYCAVES;
4988 816 }
4989 else
4990 2384 tempDMap.flags=0;
4991
4992
2/2
✓ Branch 0 taken 58880 times.
✓ Branch 1 taken 3200 times.
62080 if(s_version<7)
4993 {
4994
4/6
✓ Branch 0 taken 816 times.
✓ Branch 1 taken 2384 times.
✓ Branch 2 taken 816 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 816 times.
3200 if(tempDMap.level==0 && get_bit(deprecated_rules,14))
4995 816 tempDMap.flags|= dmfVIEWMAP;
4996 3200 }
4997
4998
2/2
✓ Branch 0 taken 58880 times.
✓ Branch 1 taken 3200 times.
62080 if(s_version<8)
4999 {
5000
4/4
✓ Branch 0 taken 816 times.
✓ Branch 1 taken 2384 times.
✓ Branch 2 taken 207 times.
✓ Branch 3 taken 609 times.
3200 if(tempDMap.level==0 && (tempDMap.type&dmfTYPE)==dmDNGN)
5001 {
5002 609 tempDMap.type &= ~dmDNGN;
5003 609 tempDMap.type |= dmCAVE;
5004 609 }
5005
2/2
✓ Branch 0 taken 855 times.
✓ Branch 1 taken 1736 times.
2591 else if((tempDMap.type&dmfTYPE)==dmCAVE)
5006 {
5007 1736 tempDMap.flags |= dmfMINIMAPCOLORFIX;
5008 1736 }
5009 3200 }
5010
5011
5/8
✓ Branch 0 taken 62080 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 128 times.
✓ Branch 3 taken 61952 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 128 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 61952 times.
62080 if(Header && ((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>=41)))
5012 61952 && (Header->zelda_version < 0x193))
5013 {
5014 if(!p_getc(&padding,f))
5015 {
5016 return qe_invalid;
5017 }
5018 }
5019
5020
2/2
✓ Branch 0 taken 42624 times.
✓ Branch 1 taken 19456 times.
62080 if(s_version >= 10)
5021 {
5022
2/4
✓ Branch 0 taken 19456 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 19456 times.
✗ Branch 3 not taken.
19456 if(!p_getc(&tempDMap.sideview,f))
5023 {
5024 return qe_invalid;
5025 }
5026 19456 }
5027
2/2
✓ Branch 0 taken 19456 times.
✓ Branch 1 taken 42624 times.
62080 if(s_version < 10) tempDMap.sideview = 0;
5028
5029 //Dmap Scripts
5030
2/2
✓ Branch 0 taken 19456 times.
✓ Branch 1 taken 42624 times.
62080 if(s_version >= 12)
5031 {
5032
2/4
✓ Branch 0 taken 19456 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 19456 times.
✗ Branch 3 not taken.
19456 if(!p_igetw(&tempDMap.script,f))
5033 {
5034 return qe_invalid;
5035 }
5036
2/2
✓ Branch 0 taken 155648 times.
✓ Branch 1 taken 19456 times.
175104 for ( int32_t q = 0; q < 8; q++ )
5037 {
5038
2/4
✓ Branch 0 taken 155648 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 155648 times.
✗ Branch 3 not taken.
155648 if(!p_igetl(&tempDMap.initD[q],f))
5039 {
5040 return qe_invalid;
5041 }
5042 155648 }
5043 19456 }
5044
2/2
✓ Branch 0 taken 19456 times.
✓ Branch 1 taken 42624 times.
62080 if ( s_version < 12 )
5045 {
5046 42624 tempDMap.script = 0;
5047
2/2
✓ Branch 0 taken 340992 times.
✓ Branch 1 taken 42624 times.
383616 for ( int32_t q = 0; q < 8; q++ )
5048 {
5049 340992 tempDMap.initD[q] = 0;
5050 340992 }
5051 42624 }
5052
5053
2/2
✓ Branch 0 taken 42624 times.
✓ Branch 1 taken 19456 times.
62080 if(s_version >= 13)
5054 {
5055
2/2
✓ Branch 0 taken 155648 times.
✓ Branch 1 taken 19456 times.
175104 for ( int32_t q = 0; q < 8; q++ )
5056 {
5057
2/2
✓ Branch 0 taken 10117120 times.
✓ Branch 1 taken 155648 times.
10272768 for ( int32_t w = 0; w < 65; w++ )
5058 {
5059
2/4
✓ Branch 0 taken 10117120 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 10117120 times.
✗ Branch 3 not taken.
10117120 if(!p_getc(&tempDMap.initD_label[q][w],f))
5060 {
5061 return qe_invalid;
5062 }
5063 10117120 }
5064 155648 }
5065 19456 }
5066
2/2
✓ Branch 0 taken 19456 times.
✓ Branch 1 taken 42624 times.
62080 if ( s_version < 13 )
5067 {
5068 42624 tempDMap.script = 0;
5069
2/2
✓ Branch 0 taken 340992 times.
✓ Branch 1 taken 42624 times.
383616 for ( int32_t q = 0; q < 8; q++ )
5070 {
5071
2/2
✓ Branch 0 taken 22164480 times.
✓ Branch 1 taken 340992 times.
22505472 for ( int32_t w = 0; w < 65; w++ )
5072 22164480 tempDMap.initD_label[q][w] = 0;
5073 340992 }
5074 42624 }
5075
2/2
✓ Branch 0 taken 19456 times.
✓ Branch 1 taken 42624 times.
62080 if(s_version >= 14)
5076 {
5077
2/4
✓ Branch 0 taken 19456 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 19456 times.
✗ Branch 3 not taken.
19456 if(!p_igetw(&tempDMap.active_sub_script,f))
5078 {
5079 return qe_invalid;
5080 }
5081
2/4
✓ Branch 0 taken 19456 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 19456 times.
✗ Branch 3 not taken.
19456 if(!p_igetw(&tempDMap.passive_sub_script,f))
5082 {
5083 return qe_invalid;
5084 }
5085
2/2
✓ Branch 0 taken 155648 times.
✓ Branch 1 taken 19456 times.
175104 for ( int32_t q = 0; q < 8; ++q )
5086 {
5087
2/4
✓ Branch 0 taken 155648 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 155648 times.
✗ Branch 3 not taken.
155648 if(!p_igetl(&tempDMap.sub_initD[q],f))
5088 {
5089 return qe_invalid;
5090 }
5091 155648 }
5092
2/2
✓ Branch 0 taken 155648 times.
✓ Branch 1 taken 19456 times.
175104 for(int32_t q = 0; q < 8; ++q)
5093 {
5094
2/2
✓ Branch 0 taken 10117120 times.
✓ Branch 1 taken 155648 times.
10272768 for ( int32_t w = 0; w < 65; ++w )
5095 {
5096
2/4
✓ Branch 0 taken 10117120 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 10117120 times.
✗ Branch 3 not taken.
10117120 if(!p_getc(&tempDMap.sub_initD_label[q][w],f))
5097 {
5098 return qe_invalid;
5099 }
5100 10117120 }
5101 155648 }
5102 19456 }
5103 else
5104 {
5105 42624 tempDMap.active_sub_script = 0;
5106 42624 tempDMap.passive_sub_script = 0;
5107
2/2
✓ Branch 0 taken 340992 times.
✓ Branch 1 taken 42624 times.
383616 for(int32_t q = 0; q < 8; ++q)
5108 {
5109 340992 tempDMap.sub_initD[q] = 0;
5110
2/2
✓ Branch 0 taken 22164480 times.
✓ Branch 1 taken 340992 times.
22505472 for(int32_t w = 0; w < 65; ++w)
5111 22164480 tempDMap.sub_initD_label[q][w] = 0;
5112 340992 }
5113 }
5114
2/2
✓ Branch 0 taken 19456 times.
✓ Branch 1 taken 42624 times.
62080 if(s_version >= 15)
5115 {
5116
2/4
✓ Branch 0 taken 19456 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 19456 times.
✗ Branch 3 not taken.
19456 if(!p_igetw(&tempDMap.onmap_script,f))
5117 {
5118 return qe_invalid;
5119 }
5120
2/2
✓ Branch 0 taken 155648 times.
✓ Branch 1 taken 19456 times.
175104 for ( int32_t q = 0; q < 8; ++q )
5121 {
5122
2/4
✓ Branch 0 taken 155648 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 155648 times.
✗ Branch 3 not taken.
155648 if(!p_igetl(&tempDMap.onmap_initD[q],f))
5123 {
5124 return qe_invalid;
5125 }
5126 155648 }
5127
2/2
✓ Branch 0 taken 155648 times.
✓ Branch 1 taken 19456 times.
175104 for(int32_t q = 0; q < 8; ++q)
5128 {
5129
2/2
✓ Branch 0 taken 10117120 times.
✓ Branch 1 taken 155648 times.
10272768 for ( int32_t w = 0; w < 65; ++w )
5130 {
5131
2/4
✓ Branch 0 taken 10117120 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 10117120 times.
✗ Branch 3 not taken.
10117120 if(!p_getc(&tempDMap.onmap_initD_label[q][w],f))
5132 {
5133 return qe_invalid;
5134 }
5135 10117120 }
5136 155648 }
5137 19456 }
5138 else
5139 {
5140 42624 tempDMap.onmap_script = 0;
5141
2/2
✓ Branch 0 taken 340992 times.
✓ Branch 1 taken 42624 times.
383616 for(int32_t q = 0; q < 8; ++q)
5142 {
5143 340992 tempDMap.onmap_initD[q] = 0;
5144
2/2
✓ Branch 0 taken 22164480 times.
✓ Branch 1 taken 340992 times.
22505472 for(int32_t w = 0; w < 65; ++w)
5145 {
5146 22164480 tempDMap.onmap_initD_label[q][w] = 0;
5147 22164480 }
5148 340992 }
5149 }
5150
2/2
✓ Branch 0 taken 19456 times.
✓ Branch 1 taken 42624 times.
62080 if(s_version >= 16)
5151 {
5152
2/4
✓ Branch 0 taken 19456 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 19456 times.
✗ Branch 3 not taken.
19456 if(!p_igetw(&tempDMap.mirrorDMap,f))
5153 {
5154 return qe_invalid;
5155 }
5156 19456 }
5157 else
5158 {
5159 42624 tempDMap.mirrorDMap = -1;
5160 }
5161
5162
2/2
✓ Branch 0 taken 47232 times.
✓ Branch 1 taken 14848 times.
62080 if (s_version >= 17)
5163 {
5164 // Reserved for z3.
5165 14848 }
5166
5167 // Enhanced music loop points
5168
2/2
✓ Branch 0 taken 14848 times.
✓ Branch 1 taken 47232 times.
62080 if (s_version >= 18)
5169 {
5170
2/4
✓ Branch 0 taken 14848 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 14848 times.
✗ Branch 3 not taken.
14848 if (!p_igetl(&tempDMap.tmusic_loop_start, f))
5171 {
5172 return qe_invalid;
5173 }
5174
2/4
✓ Branch 0 taken 14848 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 14848 times.
✗ Branch 3 not taken.
14848 if (!p_igetl(&tempDMap.tmusic_loop_end, f))
5175 {
5176 return qe_invalid;
5177 }
5178
2/4
✓ Branch 0 taken 14848 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 14848 times.
✗ Branch 3 not taken.
14848 if (!p_igetl(&tempDMap.tmusic_xfade_in, f))
5179 {
5180 return qe_invalid;
5181 }
5182
2/4
✓ Branch 0 taken 14848 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 14848 times.
✗ Branch 3 not taken.
14848 if (!p_igetl(&tempDMap.tmusic_xfade_out, f))
5183 {
5184 return qe_invalid;
5185 }
5186 14848 }
5187 else
5188 {
5189 47232 tempDMap.tmusic_loop_start = 0;
5190 47232 tempDMap.tmusic_loop_end = 0;
5191 47232 tempDMap.tmusic_xfade_in = 0;
5192 47232 tempDMap.tmusic_xfade_out = 0;
5193 }
5194
5195
2/2
✓ Branch 0 taken 14848 times.
✓ Branch 1 taken 47232 times.
62080 if(s_version >= 19)
5196
2/4
✓ Branch 0 taken 14848 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 14848 times.
✗ Branch 3 not taken.
14848 if(!p_getc(&tempDMap.overlay_subscreen, f))
5197 return qe_invalid;
5198
5199
2/2
✓ Branch 0 taken 14848 times.
✓ Branch 1 taken 47232 times.
62080 if (s_version >= 20)
5200 {
5201
2/4
✓ Branch 0 taken 14848 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 14848 times.
✗ Branch 3 not taken.
14848 if (!p_igetl(&tempDMap.intro_string_id, f))
5202 return qe_invalid;
5203 14848 }
5204 else
5205 47232 tempDMap.intro_string_id = 0;
5206
5207 // Reserved for z3.
5208
2/2
✓ Branch 0 taken 47232 times.
✓ Branch 1 taken 14848 times.
62080 if(s_version >= 21)
5209 {
5210
2/2
✓ Branch 0 taken 118784 times.
✓ Branch 1 taken 14848 times.
133632 for(int32_t j=0; j<8; j++)
5211 {
5212
2/2
✓ Branch 0 taken 950272 times.
✓ Branch 1 taken 118784 times.
1069056 for(int32_t k=0; k<8; k++)
5213 {
5214 char c;
5215
2/4
✓ Branch 0 taken 950272 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 950272 times.
✗ Branch 3 not taken.
950272 if(!p_getc(&c,f))
5216 {
5217 return qe_invalid;
5218 }
5219 950272 }
5220 118784 }
5221 14848 }
5222
5223
1/2
✓ Branch 0 taken 62080 times.
✗ Branch 1 not taken.
62080 if (!should_skip)
5224 {
5225
1/2
✓ Branch 0 taken 62080 times.
✗ Branch 1 not taken.
62080 if(loading_tileset_flags & TILESET_CLEARMAPS)
5226 tempDMap.map = 0;
5227
1/2
✓ Branch 0 taken 62080 times.
✗ Branch 1 not taken.
62080 if(loading_tileset_flags & TILESET_CLEARSCRIPTS)
5228 {
5229 tempDMap.script = 0;
5230 for(int q = 0; q < 8; ++q)
5231 tempDMap.initD[q] = 0;
5232 }
5233
1/2
✓ Branch 0 taken 62080 times.
✗ Branch 1 not taken.
62080 DMaps[i] = tempDMap;
5234 62080 }
5235 62080 }
5236
5237 131 return 0;
5238 131 }
5239
5240 115 int32_t readmisccolors(PACKFILE *f, zquestheader *Header, miscQdata *Misc)
5241 {
5242 //these are here to bypass compiler warnings about unused arguments
5243 115 Header=Header;
5244
5245 miscQdata temp_misc;
5246 115 word s_version=0, s_cversion=0;
5247 115 int32_t tempsize=0;
5248 word dummyw;
5249
5250 115 memcpy(&temp_misc,Misc,sizeof(temp_misc));
5251
5252 //section version info
5253
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 115 times.
115 if(!p_igetw(&s_version,f))
5254 {
5255 return qe_invalid;
5256 }
5257
5258 115 FFCore.quest_format[vColours] = s_version;
5259
5260 115 al_trace("Misc Colours section version: %d\n", s_version);
5261
5262 //al_trace("Misc. colors version %d\n", s_version);
5263
1/2
✓ Branch 0 taken 115 times.
✗ Branch 1 not taken.
115 if(!p_igetw(&s_cversion,f))
5264 {
5265 return qe_invalid;
5266 }
5267
5268
5269 //section size
5270
1/2
✓ Branch 0 taken 115 times.
✗ Branch 1 not taken.
115 if(!p_igetl(&tempsize,f))
5271 {
5272 return qe_invalid;
5273 }
5274
5275 //finally... section data
5276 115 readsize=0;
5277
5278
1/2
✓ Branch 0 taken 115 times.
✗ Branch 1 not taken.
115 if(!p_getc(&temp_misc.colors.text,f))
5279 {
5280 return qe_invalid;
5281 }
5282
5283
1/2
✓ Branch 0 taken 115 times.
✗ Branch 1 not taken.
115 if(!p_getc(&temp_misc.colors.caption,f))
5284 {
5285 return qe_invalid;
5286 }
5287
5288
1/2
✓ Branch 0 taken 115 times.
✗ Branch 1 not taken.
115 if(!p_getc(&temp_misc.colors.overw_bg,f))
5289 {
5290 return qe_invalid;
5291 }
5292
5293
1/2
✓ Branch 0 taken 115 times.
✗ Branch 1 not taken.
115 if(!p_getc(&temp_misc.colors.dngn_bg,f))
5294 {
5295 return qe_invalid;
5296 }
5297
5298
1/2
✓ Branch 0 taken 115 times.
✗ Branch 1 not taken.
115 if(!p_getc(&temp_misc.colors.dngn_fg,f))
5299 {
5300 return qe_invalid;
5301 }
5302
5303
1/2
✓ Branch 0 taken 115 times.
✗ Branch 1 not taken.
115 if(!p_getc(&temp_misc.colors.cave_fg,f))
5304 {
5305 return qe_invalid;
5306 }
5307
5308
1/2
✓ Branch 0 taken 115 times.
✗ Branch 1 not taken.
115 if(!p_getc(&temp_misc.colors.bs_dk,f))
5309 {
5310 return qe_invalid;
5311 }
5312
5313
1/2
✓ Branch 0 taken 115 times.
✗ Branch 1 not taken.
115 if(!p_getc(&temp_misc.colors.bs_goal,f))
5314 {
5315 return qe_invalid;
5316 }
5317
5318
1/2
✓ Branch 0 taken 115 times.
✗ Branch 1 not taken.
115 if(!p_getc(&temp_misc.colors.compass_lt,f))
5319 {
5320 return qe_invalid;
5321 }
5322
5323
1/2
✓ Branch 0 taken 115 times.
✗ Branch 1 not taken.
115 if(!p_getc(&temp_misc.colors.compass_dk,f))
5324 {
5325 return qe_invalid;
5326 }
5327
5328
1/2
✓ Branch 0 taken 115 times.
✗ Branch 1 not taken.
115 if(!p_getc(&temp_misc.colors.subscr_bg,f))
5329 {
5330 return qe_invalid;
5331 }
5332
5333
1/2
✓ Branch 0 taken 115 times.
✗ Branch 1 not taken.
115 if(!p_getc(&temp_misc.colors.triframe_color,f))
5334 {
5335 return qe_invalid;
5336 }
5337
5338
1/2
✓ Branch 0 taken 115 times.
✗ Branch 1 not taken.
115 if(!p_getc(&temp_misc.colors.hero_dot,f))
5339 {
5340 return qe_invalid;
5341 }
5342
5343
1/2
✓ Branch 0 taken 115 times.
✗ Branch 1 not taken.
115 if(!p_getc(&temp_misc.colors.bmap_bg,f))
5344 {
5345 return qe_invalid;
5346 }
5347
5348
1/2
✓ Branch 0 taken 115 times.
✗ Branch 1 not taken.
115 if(!p_getc(&temp_misc.colors.bmap_fg,f))
5349 {
5350 return qe_invalid;
5351 }
5352
5353
1/2
✓ Branch 0 taken 115 times.
✗ Branch 1 not taken.
115 if(!p_getc(&temp_misc.colors.triforce_cset,f))
5354 {
5355 return qe_invalid;
5356 }
5357
5358
1/2
✓ Branch 0 taken 115 times.
✗ Branch 1 not taken.
115 if(!p_getc(&temp_misc.colors.triframe_cset,f))
5359 {
5360 return qe_invalid;
5361 }
5362
5363
1/2
✓ Branch 0 taken 115 times.
✗ Branch 1 not taken.
115 if(!p_getc(&temp_misc.colors.overworld_map_cset,f))
5364 {
5365 return qe_invalid;
5366 }
5367
5368
1/2
✓ Branch 0 taken 115 times.
✗ Branch 1 not taken.
115 if(!p_getc(&temp_misc.colors.dungeon_map_cset,f))
5369 {
5370 return qe_invalid;
5371 }
5372
5373
1/2
✓ Branch 0 taken 115 times.
✗ Branch 1 not taken.
115 if(!p_getc(&temp_misc.colors.blueframe_cset,f))
5374 {
5375 return qe_invalid;
5376 }
5377
2/2
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 77 times.
115 if(s_version < 4)
5378 {
5379
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 if(!p_igetw(&dummyw,f))
5380 return qe_invalid;
5381 77 temp_misc.colors.triforce_tile = dummyw;
5382
5383
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 if(!p_igetw(&dummyw,f))
5384 return qe_invalid;
5385 77 temp_misc.colors.triframe_tile = dummyw;
5386
5387
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 if(!p_igetw(&dummyw,f))
5388 return qe_invalid;
5389 77 temp_misc.colors.overworld_map_tile = dummyw;
5390
5391
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 if(!p_igetw(&dummyw,f))
5392 return qe_invalid;
5393 77 temp_misc.colors.dungeon_map_tile = dummyw;
5394
5395
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 if(!p_igetw(&dummyw,f))
5396 return qe_invalid;
5397 77 temp_misc.colors.blueframe_tile = dummyw;
5398
5399
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 if(!p_igetw(&dummyw,f))
5400 return qe_invalid;
5401 77 temp_misc.colors.HCpieces_tile = dummyw;
5402 77 }
5403
5404
1/2
✓ Branch 0 taken 115 times.
✗ Branch 1 not taken.
115 if(!p_getc(&temp_misc.colors.HCpieces_cset,f))
5405 {
5406 return qe_invalid;
5407 }
5408
5409
1/2
✓ Branch 0 taken 115 times.
✗ Branch 1 not taken.
115 if(!p_getc(&temp_misc.colors.subscr_shadow,f))
5410 {
5411 return qe_invalid;
5412 }
5413
5414
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 115 times.
115 if(s_version < 2)
5415 {
5416 temp_misc.colors.msgtext = 0x01;
5417 }
5418 else
5419 {
5420
1/2
✓ Branch 0 taken 115 times.
✗ Branch 1 not taken.
115 if(!p_getc(&temp_misc.colors.msgtext, f))
5421 {
5422 return qe_invalid;
5423 }
5424 }
5425
5426
2/2
✓ Branch 0 taken 77 times.
✓ Branch 1 taken 38 times.
115 if ( s_version >= 3 ) //expanded tile pages to 825
5427 {
5428
1/2
✓ Branch 0 taken 38 times.
✗ Branch 1 not taken.
38 if(!p_igetl(&temp_misc.colors.triforce_tile,f))
5429 {
5430 return qe_invalid;
5431 }
5432
5433
1/2
✓ Branch 0 taken 38 times.
✗ Branch 1 not taken.
38 if(!p_igetl(&temp_misc.colors.triframe_tile,f))
5434 {
5435 return qe_invalid;
5436 }
5437
5438
1/2
✓ Branch 0 taken 38 times.
✗ Branch 1 not taken.
38 if(!p_igetl(&temp_misc.colors.overworld_map_tile,f))
5439 {
5440 return qe_invalid;
5441 }
5442
5443
1/2
✓ Branch 0 taken 38 times.
✗ Branch 1 not taken.
38 if(!p_igetl(&temp_misc.colors.dungeon_map_tile,f))
5444 {
5445 return qe_invalid;
5446 }
5447
5448
1/2
✓ Branch 0 taken 38 times.
✗ Branch 1 not taken.
38 if(!p_igetl(&temp_misc.colors.blueframe_tile,f))
5449 {
5450 return qe_invalid;
5451 }
5452
5453
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 38 times.
38 if(!p_igetl(&temp_misc.colors.HCpieces_tile,f))
5454 {
5455 return qe_invalid;
5456 }
5457 38 }
5458
5459 115 memcpy(Misc, &temp_misc, sizeof(temp_misc));
5460
5461 115 return 0;
5462 115 }
5463
5464 115 int32_t readgameicons(PACKFILE *f, zquestheader *, miscQdata *Misc)
5465 {
5466 miscQdata temp_misc;
5467 115 word s_version=0, s_cversion=0;
5468 byte icons;
5469 115 int32_t tempsize=0;
5470
5471 115 memcpy(&temp_misc,Misc,sizeof(temp_misc));
5472
5473 //section version info
5474
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 115 times.
115 if(!p_igetw(&s_version,f))
5475 {
5476 return qe_invalid;
5477 }
5478
5479 115 FFCore.quest_format[vIcons] = s_version;
5480
5481 //al_trace("Game icons version %d\n", s_version);
5482
1/2
✓ Branch 0 taken 115 times.
✗ Branch 1 not taken.
115 if(!p_igetw(&s_cversion,f))
5483 {
5484 return qe_invalid;
5485 }
5486
5487
5488 //section size
5489
1/2
✓ Branch 0 taken 115 times.
✗ Branch 1 not taken.
115 if(!p_igetl(&tempsize,f))
5490 {
5491 return qe_invalid;
5492 }
5493
5494 //finally... section data
5495 115 readsize=0;
5496
5497 115 icons=4;
5498
5499
2/2
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 77 times.
115 if ( s_version >= 10 )
5500 {
5501
2/2
✓ Branch 0 taken 152 times.
✓ Branch 1 taken 38 times.
190 for(int32_t i=0; i<icons; i++)
5502 {
5503
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 152 times.
152 if(!p_igetl(&temp_misc.icons[i],f))
5504 {
5505 return qe_invalid;
5506 }
5507 152 }
5508 38 }
5509 else
5510 {
5511
2/2
✓ Branch 0 taken 308 times.
✓ Branch 1 taken 77 times.
385 for(int32_t i=0; i<icons; i++)
5512 {
5513
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 308 times.
308 if(!p_igetw(&temp_misc.icons[i],f))
5514 {
5515 return qe_invalid;
5516 }
5517 308 }
5518 }
5519
5520 115 memcpy(Misc, &temp_misc, sizeof(temp_misc));
5521
5522 115 return 0;
5523 115 }
5524
5525 131 int32_t readmisc(PACKFILE *f, zquestheader *Header, miscQdata *Misc)
5526 {
5527
2/2
✓ Branch 0 taken 127 times.
✓ Branch 1 taken 4 times.
131 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_misc);
5528
5529 131 word maxinfos=256;
5530 131 word maxshops=256;
5531 131 word shops=16, infos=16, warprings=8, palcycles=256, windwarps=9, triforces=8, icons=4;
5532 131 word ponds=16, pondsize=72, expansionsize=98*2;
5533 byte tempbyte, padding;
5534 miscQdata temp_misc;
5535 131 word s_version=0, s_cversion=0;
5536 word swaptmp;
5537 131 int32_t tempsize=0;
5538
5539 131 memcpy(&temp_misc,Misc,sizeof(temp_misc));
5540
5541
2/2
✓ Branch 0 taken 33536 times.
✓ Branch 1 taken 131 times.
33667 for(int32_t i=0; i<maxshops; ++i)
5542 {
5543 33536 memset(&temp_misc.shop, 0, sizeof(shoptype)*256);
5544 33536 }
5545
5546
2/2
✓ Branch 0 taken 33536 times.
✓ Branch 1 taken 131 times.
33667 for(int32_t i=0; i<maxinfos; ++i)
5547 {
5548 33536 memset(&temp_misc.info, 0, sizeof(infotype)*256);
5549 33536 }
5550
5551
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 127 times.
131 if(Header->zelda_version > 0x192)
5552 {
5553 //section version info
5554
1/2
✓ Branch 0 taken 127 times.
✗ Branch 1 not taken.
127 if(!p_igetw(&s_version,f))
5555 {
5556 return qe_invalid;
5557 }
5558
5559 127 FFCore.quest_format[vMisc] = s_version;
5560
5561 //al_trace("Misc. data version %d\n", s_version);
5562
1/2
✓ Branch 0 taken 127 times.
✗ Branch 1 not taken.
127 if(!p_igetw(&s_cversion,f))
5563 {
5564 return qe_invalid;
5565 }
5566
5567
5568 //section size
5569
1/2
✓ Branch 0 taken 127 times.
✗ Branch 1 not taken.
127 if(!p_igetl(&tempsize,f))
5570 {
5571 return qe_invalid;
5572 }
5573 127 }
5574
5575 //finally... section data
5576 131 readsize=0;
5577
5578 //shops
5579
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 127 times.
131 if(Header->zelda_version > 0x192)
5580 {
5581
1/2
✓ Branch 0 taken 127 times.
✗ Branch 1 not taken.
127 if(!p_igetw(&shops,f))
5582 {
5583 return qe_invalid;
5584 }
5585 127 }
5586
5587
2/4
✓ Branch 0 taken 131 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 131 times.
131 if (!(shops >= 0 && shops <= NUM_SHOPS))
5588 {
5589 return qe_invalid;
5590 }
5591
5592
2/2
✓ Branch 0 taken 1488 times.
✓ Branch 1 taken 131 times.
1619 for(int32_t i=0; i<shops; i++)
5593 {
5594
2/2
✓ Branch 0 taken 223 times.
✓ Branch 1 taken 1265 times.
1488 if(s_version > 6)
5595 {
5596
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1265 times.
1265 if(!p_getstr(temp_misc.shop[i].name,sizeof(temp_misc.shop[i].name)-1,f))
5597 {
5598 return qe_invalid;
5599 }
5600 1265 }
5601
5602
2/2
✓ Branch 0 taken 4464 times.
✓ Branch 1 taken 1488 times.
5952 for(int32_t j=0; j<3; j++)
5603 {
5604
1/2
✓ Branch 0 taken 4464 times.
✗ Branch 1 not taken.
4464 if(!p_getc(&temp_misc.shop[i].item[j],f))
5605 {
5606 return qe_invalid;
5607 }
5608
5609
2/2
✓ Branch 0 taken 3795 times.
✓ Branch 1 taken 669 times.
4464 if(s_version < 4)
5610 {
5611 669 temp_misc.shop[i].hasitem[j] = (temp_misc.shop[i].item[j] == 0) ? 0 : 1;
5612 669 }
5613 4464 }
5614
5615
2/2
✓ Branch 0 taken 1424 times.
✓ Branch 1 taken 64 times.
1488 if(Header->zelda_version < 0x193)
5616 {
5617
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 64 times.
64 if(!p_getc(&tempbyte,f))
5618 {
5619 return qe_invalid;
5620 }
5621 64 }
5622
5623
2/2
✓ Branch 0 taken 4464 times.
✓ Branch 1 taken 1488 times.
5952 for(int32_t j=0; j<3; j++)
5624 {
5625
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4464 times.
4464 if(!p_igetw(&temp_misc.shop[i].price[j],f))
5626 {
5627 return qe_invalid;
5628 }
5629 4464 }
5630
5631
2/2
✓ Branch 0 taken 223 times.
✓ Branch 1 taken 1265 times.
1488 if(s_version > 3)
5632 {
5633
2/2
✓ Branch 0 taken 3795 times.
✓ Branch 1 taken 1265 times.
5060 for(int32_t j=0; j<3; j++)
5634 {
5635
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3795 times.
3795 if(!p_getc(&temp_misc.shop[i].hasitem[j],f))
5636 return qe_invalid;
5637 3795 }
5638 1265 }
5639
5640 /*
5641 if(s_version < 8)
5642 {
5643 for(int32_t j=0; j<3; j++)
5644 {
5645 (&temp_misc.shop[i].str[j])=0; //initialise.
5646 }
5647 }
5648 */
5649 1488 }
5650
5651 //filter all the 0 items to the end (yeah, bubble sort; sue me)
5652
2/2
✓ Branch 0 taken 33536 times.
✓ Branch 1 taken 131 times.
33667 for(int32_t i=0; i<maxshops; ++i)
5653 {
5654
2/2
✓ Branch 0 taken 67072 times.
✓ Branch 1 taken 33536 times.
100608 for(int32_t j=0; j<3-1; j++)
5655 {
5656
2/2
✓ Branch 0 taken 67072 times.
✓ Branch 1 taken 97581 times.
164653 for(int32_t k=0; k<2-j; k++)
5657 {
5658 97581 if(temp_misc.shop[i].hasitem[k]==0)
5659 {
5660 97581 swaptmp = temp_misc.shop[i].item[k];
5661 97581 temp_misc.shop[i].item[k] = temp_misc.shop[i].item[k+1];
5662 97581 temp_misc.shop[i].item[k+1] = swaptmp;
5663 97581 swaptmp = temp_misc.shop[i].price[k];
5664 97581 temp_misc.shop[i].price[k] = temp_misc.shop[i].price[k+1];
5665 97581 temp_misc.shop[i].price[k+1] = swaptmp;
5666 97581 swaptmp = temp_misc.shop[i].hasitem[k];
5667 97581 temp_misc.shop[i].hasitem[k] = temp_misc.shop[i].hasitem[k+1];
5668 97581 temp_misc.shop[i].hasitem[k+1] = swaptmp;
5669 97581 }
5670 97581 }
5671 67072 }
5672 33536 }
5673
5674 //infos
5675
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 127 times.
131 if(Header->zelda_version > 0x192)
5676 {
5677
1/2
✓ Branch 0 taken 127 times.
✗ Branch 1 not taken.
127 if(!p_igetw(&infos,f))
5678 {
5679 return qe_invalid;
5680 }
5681 127 }
5682
5683
2/4
✓ Branch 0 taken 131 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 131 times.
131 if (!(infos >= 0 && infos <= NUM_INFOS))
5684 {
5685 return qe_invalid;
5686 }
5687
5688
5689
2/2
✓ Branch 0 taken 1799 times.
✓ Branch 1 taken 131 times.
1930 for(int32_t i=0; i<infos; i++)
5690 {
5691
2/2
✓ Branch 0 taken 100 times.
✓ Branch 1 taken 1699 times.
1799 if(s_version > 6)
5692 {
5693
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1699 times.
1699 if(!p_getstr(temp_misc.info[i].name,sizeof(temp_misc.info[i].name)-1,f))
5694 {
5695 return qe_invalid;
5696 }
5697 1699 }
5698
5699
2/2
✓ Branch 0 taken 5397 times.
✓ Branch 1 taken 1799 times.
7196 for(int32_t j=0; j<3; j++)
5700 {
5701
2/4
✓ Branch 0 taken 5205 times.
✓ Branch 1 taken 192 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5397 if((Header->zelda_version < 0x192)||
5702
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5205 times.
5205 ((Header->zelda_version == 0x192)&&(Header->build<146)))
5703 {
5704
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 192 times.
192 if(!p_getc(&tempbyte,f))
5705 {
5706 return qe_invalid;
5707 }
5708
5709 192 temp_misc.info[i].str[j]=tempbyte;
5710 192 }
5711 else
5712 {
5713
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5205 times.
5205 if(!p_igetw(&temp_misc.info[i].str[j],f))
5714 {
5715 return qe_invalid;
5716 }
5717 }
5718 5397 }
5719
5720
2/2
✓ Branch 0 taken 1735 times.
✓ Branch 1 taken 64 times.
1799 if(Header->zelda_version < 0x193)
5721 {
5722
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&tempbyte,f))
5723 {
5724 return qe_invalid;
5725 }
5726 64 }
5727
5728
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1799 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1799 if((Header->zelda_version == 0x192)&&(Header->build>145))
5729 {
5730 if(!p_getc(&padding,f))
5731 {
5732 return qe_invalid;
5733 }
5734 }
5735
5736
2/2
✓ Branch 0 taken 5397 times.
✓ Branch 1 taken 1799 times.
7196 for(int32_t j=0; j<3; j++)
5737 {
5738
1/2
✓ Branch 0 taken 5397 times.
✗ Branch 1 not taken.
5397 if(!p_igetw(&temp_misc.info[i].price[j],f))
5739 {
5740 return qe_invalid;
5741 }
5742 5397 }
5743 1799 }
5744
5745 //filter all the 0 strings to the end (yeah, bubble sort; sue me)
5746
2/2
✓ Branch 0 taken 33536 times.
✓ Branch 1 taken 131 times.
33667 for(int32_t i=0; i<maxinfos; ++i)
5747 {
5748
2/2
✓ Branch 0 taken 67072 times.
✓ Branch 1 taken 33536 times.
100608 for(int32_t j=0; j<3-1; j++)
5749 {
5750
2/2
✓ Branch 0 taken 100608 times.
✓ Branch 1 taken 67072 times.
167680 for(int32_t k=0; k<2-j; k++)
5751 {
5752
2/2
✓ Branch 0 taken 2130 times.
✓ Branch 1 taken 98478 times.
100608 if(temp_misc.info[i].str[k]==0)
5753 {
5754 98478 swaptmp = temp_misc.info[i].str[k];
5755 98478 temp_misc.info[i].str[k] = temp_misc.info[i].str[k+1];
5756 98478 temp_misc.info[i].str[k+1] = swaptmp;
5757 98478 swaptmp = temp_misc.info[i].price[k];
5758 98478 temp_misc.info[i].price[k] = temp_misc.info[i].price[k+1];
5759 98478 temp_misc.info[i].price[k+1] = swaptmp;
5760 98478 }
5761 100608 }
5762 67072 }
5763 33536 }
5764
5765
5766 //warp rings
5767
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 115 times.
131 if(s_version > 5)
5768 115 warprings++;
5769
5770
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 127 times.
131 if(Header->zelda_version > 0x192)
5771 {
5772
1/2
✓ Branch 0 taken 127 times.
✗ Branch 1 not taken.
127 if(!p_igetw(&warprings,f))
5773 {
5774 return qe_invalid;
5775 }
5776
5777
3/4
✓ Branch 0 taken 127 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 89 times.
✓ Branch 3 taken 38 times.
127 if (!(warprings >= 0 && warprings <= NUM_WARP_RINGS))
5778 {
5779 // return qe_invalid;
5780 // Note: we can't actually fail here because for some reason, some quest files have more than the max
5781 // number of possible warp rings. Some examples of this are: demosp253.qst, yuurand.qst
5782 // So instead below we disable `keepdata` when reading the bad warp ring data, so no memory is corrupted.
5783 38 }
5784 127 }
5785
5786
2/2
✓ Branch 0 taken 1316 times.
✓ Branch 1 taken 131 times.
1447 for(int32_t i=0; i<warprings; i++)
5787 {
5788 // See above comment on the `warprings` range check.
5789 1316 bool keepdata = i < NUM_WARP_RINGS;
5790
5791
2/2
✓ Branch 0 taken 11620 times.
✓ Branch 1 taken 1316 times.
12936 for(int32_t j=0; j<8+((s_version > 5)?1:0); j++)
5792 {
5793
2/2
✓ Branch 0 taken 1792 times.
✓ Branch 1 taken 9828 times.
11620 if(s_version <= 3)
5794 {
5795
1/2
✓ Branch 0 taken 1792 times.
✗ Branch 1 not taken.
1792 if(!p_getc(&tempbyte,f))
5796 {
5797 return qe_invalid;
5798 }
5799
5800
2/2
✓ Branch 0 taken 672 times.
✓ Branch 1 taken 1120 times.
1792 if (keepdata)
5801 1120 temp_misc.warp[i].dmap[j]=(word)tempbyte;
5802 1792 }
5803 else
5804 {
5805 word tempword;
5806
1/2
✓ Branch 0 taken 9828 times.
✗ Branch 1 not taken.
9828 if(!p_igetw(&tempword,f))
5807 {
5808 return qe_invalid;
5809 }
5810
5811
2/2
✓ Branch 0 taken 513 times.
✓ Branch 1 taken 9315 times.
9828 if (keepdata)
5812 9315 temp_misc.warp[i].dmap[j] = tempword;
5813 }
5814 11620 }
5815
5816
2/2
✓ Branch 0 taken 11620 times.
✓ Branch 1 taken 1316 times.
12936 for(int32_t j=0; j<8+((s_version > 5)?1:0); j++)
5817 {
5818
1/2
✓ Branch 0 taken 11620 times.
✗ Branch 1 not taken.
11620 if(!p_getc(&tempbyte,f))
5819 {
5820 return qe_invalid;
5821 }
5822
2/2
✓ Branch 0 taken 1185 times.
✓ Branch 1 taken 10435 times.
11620 if (keepdata)
5823 10435 temp_misc.warp[i].scr[j] = tempbyte;
5824 11620 }
5825
5826
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1316 times.
1316 if(!p_getc(&tempbyte,f))
5827 {
5828 return qe_invalid;
5829 }
5830
2/2
✓ Branch 0 taken 141 times.
✓ Branch 1 taken 1175 times.
1316 if (keepdata)
5831 1175 temp_misc.warp[i].size = tempbyte;
5832
5833
2/2
✓ Branch 0 taken 1284 times.
✓ Branch 1 taken 32 times.
1316 if(Header->zelda_version < 0x193)
5834 {
5835
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32 times.
32 if(!p_getc(&tempbyte,f))
5836 {
5837 return qe_invalid;
5838 }
5839 32 }
5840 1316 }
5841
5842 //palette cycles
5843
2/2
✓ Branch 0 taken 127 times.
✓ Branch 1 taken 4 times.
131 if(Header->zelda_version < 0x193) //in 1.93+, palette cycling is saved with the palettes
5844 {
5845
2/2
✓ Branch 0 taken 1024 times.
✓ Branch 1 taken 4 times.
1028 for(int32_t i=0; i<256; i++)
5846 {
5847
2/2
✓ Branch 0 taken 3072 times.
✓ Branch 1 taken 1024 times.
4096 for(int32_t j=0; j<3; j++)
5848 {
5849 3072 temp_misc.cycles[i][j].first=0;
5850 3072 temp_misc.cycles[i][j].count=0;
5851 3072 temp_misc.cycles[i][j].speed=0;
5852 3072 }
5853 1024 }
5854
5855
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4 if((Header->zelda_version < 0x192)||
5856 ((Header->zelda_version == 0x192)&&(Header->build<73)))
5857 {
5858 4 palcycles=16;
5859 4 }
5860
5861
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 4 times.
68 for(int32_t i=0; i<palcycles; i++)
5862 {
5863
2/2
✓ Branch 0 taken 192 times.
✓ Branch 1 taken 64 times.
256 for(int32_t j=0; j<3; j++)
5864 {
5865
1/2
✓ Branch 0 taken 192 times.
✗ Branch 1 not taken.
192 if(!p_getc(&temp_misc.cycles[i][j].first,f))
5866 {
5867 return qe_invalid;
5868 }
5869
5870
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 192 times.
192 if(!p_getc(&temp_misc.cycles[i][j].count,f))
5871 {
5872 return qe_invalid;
5873 }
5874
5875
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 192 times.
192 if(!p_getc(&temp_misc.cycles[i][j].speed,f))
5876 {
5877 return qe_invalid;
5878 }
5879 192 }
5880 64 }
5881 4 }
5882
5883 //Wind warps are now just another warp ring.
5884
2/2
✓ Branch 0 taken 115 times.
✓ Branch 1 taken 16 times.
131 if(s_version <= 5)
5885 {
5886
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 12 times.
16 if(Header->zelda_version > 0x192)
5887 {
5888
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_igetw(&windwarps,f))
5889 {
5890 return qe_invalid;
5891 }
5892 12 }
5893
5894
2/4
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 16 times.
16 if (!(windwarps >= 0 && windwarps <= NUM_WARP_RINGS))
5895 {
5896 return qe_invalid;
5897 }
5898
5899
2/2
✓ Branch 0 taken 135 times.
✓ Branch 1 taken 16 times.
151 for(int32_t i=0; i<windwarps; i++)
5900 {
5901
1/2
✓ Branch 0 taken 135 times.
✗ Branch 1 not taken.
135 if(s_version <= 3)
5902 {
5903
1/2
✓ Branch 0 taken 135 times.
✗ Branch 1 not taken.
135 if(!p_getc(&tempbyte,f))
5904 {
5905 return qe_invalid;
5906 }
5907
5908 135 temp_misc.warp[8].dmap[i]=tempbyte;
5909 135 }
5910 else
5911 {
5912 if(!p_igetw(&temp_misc.warp[8].dmap[i],f))
5913 {
5914 return qe_invalid;
5915 }
5916 }
5917
5918
1/2
✓ Branch 0 taken 135 times.
✗ Branch 1 not taken.
135 if(!p_getc(&temp_misc.warp[8].scr[i],f))
5919 {
5920 return qe_invalid;
5921 }
5922
5923 135 temp_misc.warp[8].size = 9;
5924
5925
1/2
✓ Branch 0 taken 135 times.
✗ Branch 1 not taken.
135 if(s_version == 5)
5926 {
5927 if(!p_getc(&tempbyte,f))
5928 {
5929 return qe_invalid;
5930 }
5931 }
5932 135 }
5933 16 }
5934
5935
5936 //triforce pieces
5937
2/2
✓ Branch 0 taken 1048 times.
✓ Branch 1 taken 131 times.
1179 for(int32_t i=0; i<triforces; i++)
5938 {
5939
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1048 times.
1048 if(!p_getc(&temp_misc.triforce[i],f))
5940 {
5941 return qe_invalid;
5942 }
5943 1048 }
5944
5945 //misc color data
5946
2/2
✓ Branch 0 taken 115 times.
✓ Branch 1 taken 16 times.
131 if(s_version<3)
5947 {
5948
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_getc(&temp_misc.colors.text,f))
5949 {
5950 return qe_invalid;
5951 }
5952
5953
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_getc(&temp_misc.colors.caption,f))
5954 {
5955 return qe_invalid;
5956 }
5957
5958
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_getc(&temp_misc.colors.overw_bg,f))
5959 {
5960 return qe_invalid;
5961 }
5962
5963
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_getc(&temp_misc.colors.dngn_bg,f))
5964 {
5965 return qe_invalid;
5966 }
5967
5968
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_getc(&temp_misc.colors.dngn_fg,f))
5969 {
5970 return qe_invalid;
5971 }
5972
5973
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_getc(&temp_misc.colors.cave_fg,f))
5974 {
5975 return qe_invalid;
5976 }
5977
5978
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_getc(&temp_misc.colors.bs_dk,f))
5979 {
5980 return qe_invalid;
5981 }
5982
5983
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_getc(&temp_misc.colors.bs_goal,f))
5984 {
5985 return qe_invalid;
5986 }
5987
5988
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_getc(&temp_misc.colors.compass_lt,f))
5989 {
5990 return qe_invalid;
5991 }
5992
5993
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_getc(&temp_misc.colors.compass_dk,f))
5994 {
5995 return qe_invalid;
5996 }
5997
5998
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_getc(&temp_misc.colors.subscr_bg,f))
5999 {
6000 return qe_invalid;
6001 }
6002
6003
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_getc(&temp_misc.colors.triframe_color,f))
6004 {
6005 return qe_invalid;
6006 }
6007
6008
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_getc(&temp_misc.colors.hero_dot,f))
6009 {
6010 return qe_invalid;
6011 }
6012
6013
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_getc(&temp_misc.colors.bmap_bg,f))
6014 {
6015 return qe_invalid;
6016 }
6017
6018
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_getc(&temp_misc.colors.bmap_fg,f))
6019 {
6020 return qe_invalid;
6021 }
6022
6023
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_getc(&temp_misc.colors.triforce_cset,f))
6024 {
6025 return qe_invalid;
6026 }
6027
6028
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_getc(&temp_misc.colors.triframe_cset,f))
6029 {
6030 return qe_invalid;
6031 }
6032
6033
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_getc(&temp_misc.colors.overworld_map_cset,f))
6034 {
6035 return qe_invalid;
6036 }
6037
6038
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_getc(&temp_misc.colors.dungeon_map_cset,f))
6039 {
6040 return qe_invalid;
6041 }
6042
6043
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_getc(&temp_misc.colors.blueframe_cset,f))
6044 {
6045 return qe_invalid;
6046 }
6047
6048
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_igetw(&temp_misc.colors.triforce_tile,f))
6049 {
6050 return qe_invalid;
6051 }
6052
6053
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_igetw(&temp_misc.colors.triframe_tile,f))
6054 {
6055 return qe_invalid;
6056 }
6057
6058
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_igetw(&temp_misc.colors.overworld_map_tile,f))
6059 {
6060 return qe_invalid;
6061 }
6062
6063
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_igetw(&temp_misc.colors.dungeon_map_tile,f))
6064 {
6065 return qe_invalid;
6066 }
6067
6068
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_igetw(&temp_misc.colors.blueframe_tile,f))
6069 {
6070 return qe_invalid;
6071 }
6072
6073
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_igetw(&temp_misc.colors.HCpieces_tile,f))
6074 {
6075 return qe_invalid;
6076 }
6077
6078
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_getc(&temp_misc.colors.HCpieces_cset,f))
6079 {
6080 return qe_invalid;
6081 }
6082
6083 16 temp_misc.colors.msgtext = 0x01;
6084
6085
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 4 times.
16 if(Header->zelda_version < 0x193)
6086 {
6087
2/2
✓ Branch 0 taken 28 times.
✓ Branch 1 taken 4 times.
32 for(int32_t i=0; i<7; i++)
6088 {
6089
1/2
✓ Branch 0 taken 28 times.
✗ Branch 1 not taken.
28 if(!p_getc(&tempbyte,f))
6090 {
6091 return qe_invalid;
6092 }
6093 28 }
6094 4 }
6095
6096
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
16 if((Header->zelda_version == 0x192)&&(Header->build>145))
6097 {
6098 for(int32_t i=0; i<256; i++)
6099 {
6100 if(!p_getc(&tempbyte,f))
6101 {
6102 return qe_invalid;
6103 }
6104 }
6105 }
6106
6107
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(s_version>1)
6108 {
6109 if(!p_getc(&temp_misc.colors.subscr_shadow,f))
6110 {
6111 return qe_invalid;
6112 }
6113 }
6114
6115 //save game icons
6116
2/4
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
16 if((Header->zelda_version < 0x192)||
6117
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 ((Header->zelda_version == 0x192)&&(Header->build<73)))
6118 {
6119 4 icons=3;
6120 4 }
6121
6122
2/2
✓ Branch 0 taken 60 times.
✓ Branch 1 taken 16 times.
76 for(int32_t i=0; i<icons; i++)
6123 {
6124
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_igetw(&temp_misc.icons[i],f))
6125 {
6126 return qe_invalid;
6127 }
6128 60 }
6129 16 }
6130
6131
2/4
✓ Branch 0 taken 127 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
131 if((Header->zelda_version < 0x192)||
6132
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 127 times.
127 ((Header->zelda_version == 0x192)&&(Header->build<30)))
6133 {
6134 4 memcpy(Misc, &temp_misc, sizeof(temp_misc));
6135
6136 4 return 0;
6137 }
6138
6139 //pond information
6140
1/2
✓ Branch 0 taken 127 times.
✗ Branch 1 not taken.
127 if(Header->zelda_version < 0x193)
6141 {
6142 if((Header->zelda_version == 0x192)&&(Header->build<146))
6143 {
6144 pondsize=25;
6145 }
6146
6147 for(int32_t i=0; i<ponds; i++)
6148 {
6149 for(int32_t j=0; j<pondsize; j++)
6150 {
6151 if(!p_getc(&tempbyte,f))
6152 {
6153 return qe_invalid;
6154
6155 }
6156 }
6157 }
6158 }
6159
6160 //end string
6161
1/4
✓ Branch 0 taken 127 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
127 if((Header->zelda_version < 0x192)||
6162
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 127 times.
127 ((Header->zelda_version == 0x192)&&(Header->build<146)))
6163 {
6164 if(!p_getc(&tempbyte,f))
6165 {
6166 return qe_invalid;
6167 }
6168
6169 temp_misc.endstring=tempbyte;
6170
6171 if(!p_getc(&tempbyte,f))
6172 {
6173 return qe_invalid;
6174 }
6175 }
6176 else
6177 {
6178
1/2
✓ Branch 0 taken 127 times.
✗ Branch 1 not taken.
127 if(!p_igetw(&temp_misc.endstring,f))
6179 {
6180 return qe_invalid;
6181 }
6182 }
6183
6184 //expansion
6185
1/2
✓ Branch 0 taken 127 times.
✗ Branch 1 not taken.
127 if(Header->zelda_version < 0x193)
6186 {
6187 if((Header->zelda_version == 0x192)&&(Header->build<73))
6188 {
6189 expansionsize=99*2;
6190 }
6191
6192 for(int32_t i=0; i<expansionsize; i++)
6193 {
6194 if(!p_getc(&tempbyte,f))
6195 {
6196 return qe_invalid;
6197 }
6198 }
6199 }
6200 //shops v8
6201
6202
6203
2/2
✓ Branch 0 taken 89 times.
✓ Branch 1 taken 38 times.
127 if(s_version >= 8)
6204 {
6205
2/2
✓ Branch 0 taken 560 times.
✓ Branch 1 taken 38 times.
598 for(int32_t i=0; i<shops; i++)
6206 {
6207
2/2
✓ Branch 0 taken 1680 times.
✓ Branch 1 taken 560 times.
2240 for(int32_t j=0; j<3; j++)
6208 {
6209
1/2
✓ Branch 0 taken 1680 times.
✗ Branch 1 not taken.
1680 if(!p_igetw(&temp_misc.shop[i].str[j],f))
6210 return qe_invalid;
6211 1680 }
6212 560 }
6213 38 }
6214
6215 127 memset(&temp_misc.questmisc, 0, sizeof(int32_t)*32);
6216 127 memset(&temp_misc.questmisc_strings, 0, sizeof(char)*4096);
6217 127 memset(&temp_misc.zscript_last_compiled_version, 0, sizeof(int32_t));
6218
6219 //v9 includes quest misc[32]
6220
2/2
✓ Branch 0 taken 89 times.
✓ Branch 1 taken 38 times.
127 if(s_version >= 9)
6221 {
6222
2/2
✓ Branch 0 taken 1216 times.
✓ Branch 1 taken 38 times.
1254 for ( int32_t q = 0; q < 32; q++ )
6223 {
6224
1/2
✓ Branch 0 taken 1216 times.
✗ Branch 1 not taken.
1216 if(!p_igetl(&temp_misc.questmisc[q],f))
6225 return qe_invalid;
6226 1216 }
6227
2/2
✓ Branch 0 taken 1216 times.
✓ Branch 1 taken 38 times.
1254 for ( int32_t q = 0; q < 32; q++ )
6228 {
6229
2/2
✓ Branch 0 taken 155648 times.
✓ Branch 1 taken 1216 times.
156864 for ( int32_t j = 0; j < 128; j++ )
6230
1/2
✓ Branch 0 taken 155648 times.
✗ Branch 1 not taken.
155648 if(!p_getc(&temp_misc.questmisc_strings[q][j],f))
6231 return qe_invalid;
6232 1216 }
6233 38 }
6234
6235
2/2
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 89 times.
127 if(s_version >= 11 )
6236 {
6237
1/2
✓ Branch 0 taken 38 times.
✗ Branch 1 not taken.
38 if(!p_igetl(&temp_misc.zscript_last_compiled_version,f))
6238 return qe_invalid;
6239 38 }
6240
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 89 times.
89 else if(s_version < 11 )
6241 {
6242 89 temp_misc.zscript_last_compiled_version = -1;
6243 89 }
6244
6245 127 FFCore.quest_format[vLastCompile] = temp_misc.zscript_last_compiled_version;
6246
6247
2/2
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 89 times.
127 if(s_version >= 12)
6248 {
6249 byte spr;
6250
2/2
✓ Branch 0 taken 9728 times.
✓ Branch 1 taken 38 times.
9766 for(int32_t q = 0; q < sprMAX; ++q)
6251 {
6252
1/2
✓ Branch 0 taken 9728 times.
✗ Branch 1 not taken.
9728 if(!p_getc(&spr,f))
6253 return qe_invalid;
6254 9728 temp_misc.sprites[q] = spr;
6255 9728 }
6256 38 }
6257 else
6258 {
6259 89 memset(&(temp_misc.sprites), 0, sizeof(temp_misc.sprites));
6260 //temp_misc.sprites[sprFALL] = ;
6261 }
6262
6263
2/2
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 89 times.
127 if(s_version >= 13)
6264 {
6265
2/2
✓ Branch 0 taken 2432 times.
✓ Branch 1 taken 38 times.
2470 for(size_t q = 0; q < 64; ++q)
6266 {
6267 2432 bottletype* bt = &(temp_misc.bottle_types[q]);
6268
1/2
✓ Branch 0 taken 2432 times.
✗ Branch 1 not taken.
2432 if (!p_getstr(bt->name, sizeof(bt->name)-1, f))
6269 return qe_invalid;
6270
2/2
✓ Branch 0 taken 7296 times.
✓ Branch 1 taken 2432 times.
9728 for(size_t j = 0; j < 3; ++j)
6271 {
6272
1/2
✓ Branch 0 taken 7296 times.
✗ Branch 1 not taken.
7296 if (!p_getc(&(bt->counter[j]), f))
6273 return qe_invalid;
6274
1/2
✓ Branch 0 taken 7296 times.
✗ Branch 1 not taken.
7296 if (!p_igetw(&(bt->amount[j]), f))
6275 return qe_invalid;
6276 7296 }
6277
1/2
✓ Branch 0 taken 2432 times.
✗ Branch 1 not taken.
2432 if (!p_getc(&(bt->flags), f))
6278 return qe_invalid;
6279
1/2
✓ Branch 0 taken 2432 times.
✗ Branch 1 not taken.
2432 if (!p_getc(&(bt->next_type), f))
6280 return qe_invalid;
6281 2432 }
6282
2/2
✓ Branch 0 taken 9728 times.
✓ Branch 1 taken 38 times.
9766 for(size_t q = 0; q < 256; ++q)
6283 {
6284 9728 bottleshoptype* bst = &(temp_misc.bottle_shop_types[q]);
6285
1/2
✓ Branch 0 taken 9728 times.
✗ Branch 1 not taken.
9728 if (!pfread(bst->name, sizeof(bst->name)-1, f))
6286 return qe_invalid;
6287
2/2
✓ Branch 0 taken 29184 times.
✓ Branch 1 taken 9728 times.
38912 for(size_t j = 0; j < 3; ++j)
6288 {
6289
1/2
✓ Branch 0 taken 29184 times.
✗ Branch 1 not taken.
29184 if (!p_getc(&(bst->fill[j]), f))
6290 return qe_invalid;
6291
1/2
✓ Branch 0 taken 29184 times.
✗ Branch 1 not taken.
29184 if (!p_igetw(&(bst->comb[j]), f))
6292 return qe_invalid;
6293
1/2
✓ Branch 0 taken 29184 times.
✗ Branch 1 not taken.
29184 if (!p_getc(&(bst->cset[j]), f))
6294 return qe_invalid;
6295
1/2
✓ Branch 0 taken 29184 times.
✗ Branch 1 not taken.
29184 if (!p_igetw(&(bst->price[j]), f))
6296 return qe_invalid;
6297
1/2
✓ Branch 0 taken 29184 times.
✗ Branch 1 not taken.
29184 if (!p_igetw(&(bst->str[j]), f))
6298 return qe_invalid;
6299 29184 }
6300 9728 }
6301 38 }
6302 else
6303 {
6304
2/2
✓ Branch 0 taken 5696 times.
✓ Branch 1 taken 89 times.
5785 for(size_t q = 0; q < 64; ++q)
6305 5696 temp_misc.bottle_types[q].clear();
6306
2/2
✓ Branch 0 taken 22784 times.
✓ Branch 1 taken 89 times.
22873 for(size_t q = 0; q < 256; ++q)
6307 22784 temp_misc.bottle_shop_types[q].clear();
6308 }
6309
6310
2/2
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 89 times.
127 if(s_version >= 14)
6311 {
6312 byte msfx;
6313
2/2
✓ Branch 0 taken 9728 times.
✓ Branch 1 taken 38 times.
9766 for(int32_t q = 0; q < sfxMAX; ++q)
6314 {
6315
1/2
✓ Branch 0 taken 9728 times.
✗ Branch 1 not taken.
9728 if(!p_getc(&msfx,f))
6316 return qe_invalid;
6317 9728 temp_misc.miscsfx[q] = msfx;
6318 9728 }
6319 38 }
6320 else
6321 {
6322 89 memset(&(temp_misc.miscsfx), 0, sizeof(temp_misc.miscsfx));
6323 89 temp_misc.miscsfx[sfxBUSHGRASS] = WAV_ZN1GRASSCUT;
6324 89 temp_misc.miscsfx[sfxLOWHEART] = WAV_ER;
6325 }
6326
2/2
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 89 times.
127 if(s_version < 15)
6327 {
6328 89 temp_misc.miscsfx[sfxHURTPLAYER] = WAV_OUCH;
6329 89 temp_misc.miscsfx[sfxHAMMERPOUND] = WAV_ZN1HAMMERPOST;
6330 89 temp_misc.miscsfx[sfxSUBSCR_ITEM_ASSIGN] = WAV_PLACE;
6331 89 temp_misc.miscsfx[sfxSUBSCR_CURSOR_MOVE] = WAV_CHIME;
6332 89 temp_misc.miscsfx[sfxREFILL] = WAV_MSG;
6333 89 temp_misc.miscsfx[sfxDRAIN] = WAV_MSG;
6334 89 }
6335
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 119 times.
127 if(s_version < 16)
6336 {
6337 119 temp_misc.miscsfx[sfxTAP] = WAV_ZN1TAP;
6338 119 temp_misc.miscsfx[sfxTAP_HOLLOW] = WAV_ZN1TAP2;
6339 119 }
6340
6341
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 127 times.
127 if (!should_skip)
6342 127 memcpy(Misc, &temp_misc, sizeof(temp_misc));
6343
6344 127 return 0;
6345 131 }
6346
6347 extern char *item_string[MAXITEMS];
6348 extern const char *old_item_string[iLast];
6349 extern char *weapon_string[MAXWPNS];
6350 extern const char *old_weapon_string[wLast];
6351
6352 131 int32_t readitems(PACKFILE *f, word version, word build)
6353 {
6354
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 127 times.
131 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_items);
6355
6356 byte padding;
6357 int32_t dummy;
6358 131 word items_to_read=MAXITEMS;
6359 itemdata tempitem;
6360 131 word s_version=0, s_cversion=0;
6361 word dummy_word;
6362
6363
1/2
✓ Branch 0 taken 131 times.
✗ Branch 1 not taken.
131 if(version < 0x186)
6364 {
6365 items_to_read=64;
6366 }
6367
6368
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 127 times.
131 if(version > 0x192)
6369 {
6370 127 items_to_read=0;
6371
6372 //section version info
6373
1/2
✓ Branch 0 taken 127 times.
✗ Branch 1 not taken.
127 if(!p_igetw(&s_version,f))
6374 {
6375 return qe_invalid;
6376 }
6377
6378 127 FFCore.quest_format[vItems] = s_version;
6379
6380 //al_trace("Items version %d\n", s_version);
6381
1/2
✓ Branch 0 taken 127 times.
✗ Branch 1 not taken.
127 if(!p_igetw(&s_cversion,f))
6382 {
6383 return qe_invalid;
6384 }
6385
6386 //section size
6387
1/2
✓ Branch 0 taken 127 times.
✗ Branch 1 not taken.
127 if(!p_igetl(&dummy,f))
6388 {
6389 return qe_invalid;
6390 }
6391
6392 //finally... section data
6393
1/2
✓ Branch 0 taken 127 times.
✗ Branch 1 not taken.
127 if(!p_igetw(&items_to_read,f))
6394 {
6395 return qe_invalid;
6396 }
6397
6398
2/4
✓ Branch 0 taken 127 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 127 times.
127 if (!(items_to_read >= 0 && items_to_read <= MAXITEMS))
6399 {
6400 return qe_invalid;
6401 }
6402 127 }
6403
6404
2/2
✓ Branch 0 taken 115 times.
✓ Branch 1 taken 16 times.
131 if(s_version>1)
6405 {
6406
2/2
✓ Branch 0 taken 29440 times.
✓ Branch 1 taken 115 times.
29555 for(int32_t i=0; i<items_to_read; i++)
6407 {
6408 char tempname[64];
6409
6410
1/2
✓ Branch 0 taken 29440 times.
✗ Branch 1 not taken.
29440 if(!pfread(tempname, 64, f))
6411 {
6412 return qe_invalid;
6413 }
6414
6415 29440 item_string[i][0] = '\0';
6416 29440 strncat(item_string[i], tempname, 64 - 1);
6417 29440 }
6418 115 }
6419
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 else if (!should_skip)
6420 {
6421
2/2
✓ Branch 0 taken 4096 times.
✓ Branch 1 taken 16 times.
4112 for(int32_t i=0; i<MAXITEMS; i++)
6422 {
6423 4096 reset_itemname(i);
6424 4096 }
6425 16 }
6426
6427
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 131 times.
131 if (!should_skip)
6428
2/2
✓ Branch 0 taken 33536 times.
✓ Branch 1 taken 131 times.
33667 for(int32_t i=0; i<MAXITEMS; i++)
6429 {
6430 33536 itemdata& id = itemsbuf[i];
6431 33536 memset(&id, 0, sizeof(itemdata));
6432 33536 id.count=-1;
6433 33536 id.playsound=WAV_SCALE;
6434 33536 reset_itembuf(&id,i);
6435 33667 }
6436
6437
2/2
✓ Branch 0 taken 31304 times.
✓ Branch 1 taken 131 times.
31435 for(int32_t i=0; i<items_to_read; i++)
6438 {
6439 31304 memset(&tempitem, 0, sizeof(itemdata));
6440 31304 reset_itembuf(&tempitem,i);
6441
6442
6443
2/2
✓ Branch 0 taken 9728 times.
✓ Branch 1 taken 21576 times.
31304 if ( s_version > 35 ) //expanded tiles
6444 {
6445
1/2
✓ Branch 0 taken 9728 times.
✗ Branch 1 not taken.
9728 if(!p_igetl(&tempitem.tile,f))
6446 {
6447 return qe_invalid;
6448 }
6449 9728 }
6450 else
6451 {
6452
1/2
✓ Branch 0 taken 21576 times.
✗ Branch 1 not taken.
21576 if(!p_igetw(&tempitem.tile,f))
6453 {
6454 return qe_invalid;
6455 }
6456 }
6457
6458
1/2
✓ Branch 0 taken 31304 times.
✗ Branch 1 not taken.
31304 if(!p_getc(&tempitem.misc_flags,f))
6459 {
6460 return qe_invalid;
6461 }
6462
6463
1/2
✓ Branch 0 taken 31304 times.
✗ Branch 1 not taken.
31304 if(!p_getc(&tempitem.csets,f))
6464 {
6465 return qe_invalid;
6466 }
6467
6468
1/2
✓ Branch 0 taken 31304 times.
✗ Branch 1 not taken.
31304 if(!p_getc(&tempitem.frames,f))
6469 {
6470 return qe_invalid;
6471 }
6472
6473
1/2
✓ Branch 0 taken 31304 times.
✗ Branch 1 not taken.
31304 if(!p_getc(&tempitem.speed,f))
6474 {
6475 return qe_invalid;
6476 }
6477
6478
1/2
✓ Branch 0 taken 31304 times.
✗ Branch 1 not taken.
31304 if(!p_getc(&tempitem.delay,f))
6479 {
6480 return qe_invalid;
6481 }
6482
6483
2/2
✓ Branch 0 taken 30280 times.
✓ Branch 1 taken 1024 times.
31304 if(version < 0x193)
6484 {
6485
1/2
✓ Branch 0 taken 1024 times.
✗ Branch 1 not taken.
1024 if(!p_getc(&padding,f))
6486 {
6487 return qe_invalid;
6488 }
6489
6490
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1024 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1024 if((version < 0x192)||((version == 0x192)&&(build<186)))
6491 {
6492
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1024 times.
1024 if (should_skip)
6493 continue;
6494
6495
3/3
✓ Branch 0 taken 1016 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 4 times.
1024 switch(i)
6496 {
6497 case iShield:
6498 4 tempitem.ltm=get_qr(qr_BSZELDA)?-12:10;
6499 4 break;
6500
6501 case iMShield:
6502 4 tempitem.ltm=get_qr(qr_BSZELDA)?-6:-10;
6503 4 break;
6504
6505 default:
6506 1016 tempitem.ltm=0;
6507 1016 break;
6508 }
6509
6510 1024 tempitem.count=-1;
6511 1024 tempitem.flags=tempitem.wpn=tempitem.wpn2=tempitem.wpn3=tempitem.wpn3=tempitem.pickup_hearts=
6512 1024 tempitem.misc1=tempitem.misc2=tempitem.usesound=0;
6513 1024 tempitem.family=0xFF;
6514 1024 tempitem.playsound=WAV_SCALE;
6515 1024 reset_itembuf(&tempitem,i);
6516
6517 1024 memcpy(&itemsbuf[i], &tempitem, sizeof(itemdata));
6518
6519 1024 continue;
6520 }
6521 }
6522
6523
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30280 times.
30280 if(!p_igetl(&tempitem.ltm,f))
6524 {
6525 return qe_invalid;
6526 }
6527
6528
1/2
✓ Branch 0 taken 30280 times.
✗ Branch 1 not taken.
30280 if(version < 0x193)
6529 {
6530 for(int32_t q=0; q<12; q++)
6531 {
6532 if(!p_getc(&padding,f))
6533 {
6534 return qe_invalid;
6535 }
6536 }
6537 }
6538
6539
2/2
✓ Branch 0 taken 29440 times.
✓ Branch 1 taken 840 times.
30280 if(s_version>1)
6540 {
6541
2/2
✓ Branch 0 taken 9728 times.
✓ Branch 1 taken 19712 times.
29440 if ( s_version >= 31 )
6542 {
6543
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9728 times.
9728 if(!p_igetl(&tempitem.family,f))
6544 {
6545 return qe_invalid;
6546 }
6547 9728 }
6548 else
6549 {
6550
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 19712 times.
19712 if(!p_getc(&tempitem.family,f))
6551 {
6552 return qe_invalid;
6553 }
6554 }
6555
1/2
✓ Branch 0 taken 29440 times.
✗ Branch 1 not taken.
29440 if(s_version < 16)
6556 if(tempitem.family == 0xFF)
6557 tempitem.family = itype_misc;
6558
6559
1/2
✓ Branch 0 taken 29440 times.
✗ Branch 1 not taken.
29440 if(!p_getc(&tempitem.fam_type,f))
6560 {
6561 return qe_invalid;
6562 }
6563
6564
1/2
✓ Branch 0 taken 29440 times.
✗ Branch 1 not taken.
29440 if(s_version>5)
6565 {
6566
2/2
✓ Branch 0 taken 9728 times.
✓ Branch 1 taken 19712 times.
29440 if(s_version>=31)
6567 {
6568
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9728 times.
9728 if(!p_igetl(&tempitem.power,f))
6569 {
6570 return qe_invalid;
6571 }
6572 9728 }
6573 else
6574 {
6575
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 19712 times.
19712 if(!p_getc(&tempitem.power,f))
6576 {
6577 return qe_invalid;
6578 }
6579 }
6580
6581 //converted flags from 16b to 32b -Z
6582
2/2
✓ Branch 0 taken 19712 times.
✓ Branch 1 taken 9728 times.
29440 if ( s_version < 41 )
6583 {
6584
1/2
✓ Branch 0 taken 19712 times.
✗ Branch 1 not taken.
19712 if(!p_igetw(&tempitem.flags,f))
6585 {
6586 return qe_invalid;
6587 }
6588 19712 }
6589 else
6590 {
6591
1/2
✓ Branch 0 taken 9728 times.
✗ Branch 1 not taken.
9728 if(!p_igetl(&tempitem.flags,f))
6592 {
6593 return qe_invalid;
6594 }
6595 }
6596 29440 }
6597 else
6598 {
6599 //tempitem.power = tempitem.fam_type;
6600 char tempchar;
6601
6602 if(!p_getc(&tempchar,f))
6603 {
6604 return qe_invalid;
6605 }
6606
6607 tempitem.flags |= (tempchar ? ITEM_GAMEDATA : 0);
6608 }
6609
6610
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29440 times.
29440 if(!p_igetw(&tempitem.script,f))
6611 {
6612 return qe_invalid;
6613 }
6614
6615
1/2
✓ Branch 0 taken 29440 times.
✗ Branch 1 not taken.
29440 if(s_version<=3)
6616 {
6617 if(tempitem.script > NUMSCRIPTITEM)
6618 {
6619 tempitem.script = 0;
6620 }
6621 }
6622
6623
1/2
✓ Branch 0 taken 29440 times.
✗ Branch 1 not taken.
29440 if(!p_getc(&tempitem.count,f))
6624 {
6625 return qe_invalid;
6626 }
6627
6628
1/2
✓ Branch 0 taken 29440 times.
✗ Branch 1 not taken.
29440 if(!p_igetw(&tempitem.amount,f))
6629 {
6630 return qe_invalid;
6631 }
6632
6633
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29440 times.
29440 if(!p_igetw(&tempitem.collect_script,f))
6634 {
6635 return qe_invalid;
6636 }
6637
6638
1/2
✓ Branch 0 taken 29440 times.
✗ Branch 1 not taken.
29440 if(s_version<=3)
6639 {
6640 if(tempitem.collect_script > NUMSCRIPTITEM)
6641 {
6642 tempitem.collect_script = 0;
6643 }
6644 }
6645
6646
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29440 times.
29440 if(!p_igetw(&tempitem.setmax,f))
6647 {
6648 return qe_invalid;
6649 }
6650
6651
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29440 times.
29440 if(!p_igetw(&tempitem.max,f))
6652 {
6653 return qe_invalid;
6654 }
6655
6656
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29440 times.
29440 if(!p_getc(&tempitem.playsound,f))
6657 {
6658 return qe_invalid;
6659 }
6660
6661
2/2
✓ Branch 0 taken 235520 times.
✓ Branch 1 taken 29440 times.
264960 for(int32_t j=0; j<8; j++)
6662 {
6663
1/2
✓ Branch 0 taken 235520 times.
✗ Branch 1 not taken.
235520 if(!p_igetl(&tempitem.initiald[j],f))
6664 {
6665 return qe_invalid;
6666 }
6667 235520 }
6668
6669
2/2
✓ Branch 0 taken 58880 times.
✓ Branch 1 taken 29440 times.
88320 for(int32_t j=0; j<2; j++)
6670 {
6671
1/2
✓ Branch 0 taken 58880 times.
✗ Branch 1 not taken.
58880 if(!p_getc(&tempitem.initiala[j],f))
6672 {
6673 return qe_invalid;
6674 }
6675 58880 }
6676
6677
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29440 times.
29440 if(s_version>4)
6678 {
6679
1/2
✓ Branch 0 taken 29440 times.
✗ Branch 1 not taken.
29440 if(s_version>5)
6680 {
6681
1/2
✓ Branch 0 taken 29440 times.
✗ Branch 1 not taken.
29440 if(!p_getc(&tempitem.wpn,f))
6682 {
6683 return qe_invalid;
6684 }
6685
6686
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29440 times.
29440 if(!p_getc(&tempitem.wpn2,f))
6687 {
6688 return qe_invalid;
6689 }
6690
6691
1/2
✓ Branch 0 taken 29440 times.
✗ Branch 1 not taken.
29440 if(!p_getc(&tempitem.wpn3,f))
6692 {
6693 return qe_invalid;
6694 }
6695
6696
1/2
✓ Branch 0 taken 29440 times.
✗ Branch 1 not taken.
29440 if(!p_getc(&tempitem.wpn4,f))
6697 {
6698 return qe_invalid;
6699 }
6700
6701
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29440 times.
29440 if(s_version>=15)
6702 {
6703
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29440 times.
29440 if(!p_getc(&tempitem.wpn5,f))
6704 {
6705 return qe_invalid;
6706 }
6707
6708
1/2
✓ Branch 0 taken 29440 times.
✗ Branch 1 not taken.
29440 if(!p_getc(&tempitem.wpn6,f))
6709 {
6710 return qe_invalid;
6711 }
6712
6713
1/2
✓ Branch 0 taken 29440 times.
✗ Branch 1 not taken.
29440 if(!p_getc(&tempitem.wpn7,f))
6714 {
6715 return qe_invalid;
6716 }
6717
6718
1/2
✓ Branch 0 taken 29440 times.
✗ Branch 1 not taken.
29440 if(!p_getc(&tempitem.wpn8,f))
6719 {
6720 return qe_invalid;
6721 }
6722
6723
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29440 times.
29440 if(!p_getc(&tempitem.wpn9,f))
6724 {
6725 return qe_invalid;
6726 }
6727
6728
1/2
✓ Branch 0 taken 29440 times.
✗ Branch 1 not taken.
29440 if(!p_getc(&tempitem.wpn10,f))
6729 {
6730 return qe_invalid;
6731 }
6732 29440 }
6733
6734
1/2
✓ Branch 0 taken 29440 times.
✗ Branch 1 not taken.
29440 if(!p_getc(&tempitem.pickup_hearts,f))
6735 {
6736 return qe_invalid;
6737 }
6738
6739
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29440 times.
29440 if(s_version<15)
6740 {
6741 if(!p_igetw(&dummy_word,f))
6742 {
6743 return qe_invalid;
6744 }
6745
6746 tempitem.misc1=dummy_word;
6747
6748 if(!p_igetw(&dummy_word,f))
6749 {
6750 return qe_invalid;
6751 }
6752
6753 tempitem.misc2=dummy_word;
6754 }
6755 else
6756 {
6757
1/2
✓ Branch 0 taken 29440 times.
✗ Branch 1 not taken.
29440 if(!p_igetl(&tempitem.misc1,f))
6758 {
6759 return qe_invalid;
6760 }
6761
6762
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29440 times.
29440 if(!p_igetl(&tempitem.misc2,f))
6763 {
6764 return qe_invalid;
6765 }
6766
6767 // Version 24: shICE -> shSCRIPT; previously, all shields could block script weapons
6768
1/2
✓ Branch 0 taken 29440 times.
✗ Branch 1 not taken.
29440 if(s_version<24)
6769 {
6770 if(tempitem.family==itype_shield)
6771 {
6772 tempitem.misc1|=shSCRIPT;
6773 }
6774 }
6775 }
6776
6777
2/2
✓ Branch 0 taken 19712 times.
✓ Branch 1 taken 9728 times.
29440 if(s_version < 53)
6778 {
6779 byte tempbyte;
6780
1/2
✓ Branch 0 taken 19712 times.
✗ Branch 1 not taken.
19712 if(!p_getc(&tempbyte,f))
6781 {
6782 return qe_invalid;
6783 }
6784 19712 tempitem.cost_amount[0] = tempbyte;
6785 19712 }
6786 else
6787 {
6788
2/2
✓ Branch 0 taken 19456 times.
✓ Branch 1 taken 9728 times.
29184 for(auto q = 0; q < 2; ++q)
6789 {
6790
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 19456 times.
19456 if(!p_igetw(&tempitem.cost_amount[q],f))
6791 {
6792 return qe_invalid;
6793 }
6794 19456 }
6795 }
6796 29440 }
6797 else
6798 {
6799 char tempchar;
6800
6801 if(!p_getc(&tempchar,f))
6802 {
6803 return qe_invalid;
6804 }
6805
6806 tempitem.flags |= (tempchar ? ITEM_EDIBLE : 0);
6807 }
6808
6809 // June 2007: more misc. attributes
6810
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29440 times.
29440 if(s_version>=12)
6811 {
6812
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29440 times.
29440 if(s_version<15)
6813 {
6814 if(!p_igetw(&dummy_word,f))
6815 {
6816 return qe_invalid;
6817 }
6818
6819 tempitem.misc3=dummy_word;
6820
6821 if(!p_igetw(&dummy_word,f))
6822 {
6823 return qe_invalid;
6824 }
6825
6826 tempitem.misc4=dummy_word;
6827 }
6828 else
6829 {
6830
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29440 times.
29440 if(!p_igetl(&tempitem.misc3,f))
6831 {
6832 return qe_invalid;
6833 }
6834
6835
1/2
✓ Branch 0 taken 29440 times.
✗ Branch 1 not taken.
29440 if(!p_igetl(&tempitem.misc4,f))
6836 {
6837 return qe_invalid;
6838 }
6839
6840
1/2
✓ Branch 0 taken 29440 times.
✗ Branch 1 not taken.
29440 if(!p_igetl(&tempitem.misc5,f))
6841 {
6842 return qe_invalid;
6843 }
6844
6845
1/2
✓ Branch 0 taken 29440 times.
✗ Branch 1 not taken.
29440 if(!p_igetl(&tempitem.misc6,f))
6846 {
6847 return qe_invalid;
6848 }
6849
6850
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29440 times.
29440 if(!p_igetl(&tempitem.misc7,f))
6851 {
6852 return qe_invalid;
6853 }
6854
6855
1/2
✓ Branch 0 taken 29440 times.
✗ Branch 1 not taken.
29440 if(!p_igetl(&tempitem.misc8,f))
6856 {
6857 return qe_invalid;
6858 }
6859
6860
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29440 times.
29440 if(!p_igetl(&tempitem.misc9,f))
6861 {
6862 return qe_invalid;
6863 }
6864
6865
1/2
✓ Branch 0 taken 29440 times.
✗ Branch 1 not taken.
29440 if(!p_igetl(&tempitem.misc10,f))
6866 {
6867 return qe_invalid;
6868 }
6869 }
6870
6871
1/2
✓ Branch 0 taken 29440 times.
✗ Branch 1 not taken.
29440 if(!p_getc(&tempitem.usesound,f))
6872 {
6873 return qe_invalid;
6874 }
6875
6876
2/2
✓ Branch 0 taken 9728 times.
✓ Branch 1 taken 19712 times.
29440 if(s_version >= 49)
6877 {
6878
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9728 times.
9728 if(!p_getc(&tempitem.usesound2,f))
6879 {
6880 return qe_invalid;
6881 }
6882 9728 }
6883 19712 else tempitem.usesound2 = 0;
6884
6885
3/4
✓ Branch 0 taken 19712 times.
✓ Branch 1 taken 9728 times.
✓ Branch 2 taken 19712 times.
✗ Branch 3 not taken.
29440 if(s_version < 50 && tempitem.family == itype_mirror)
6886 {
6887 //Split continue/dmap warp effect/sfx, port for old
6888 tempitem.misc2 = tempitem.misc1;
6889 tempitem.usesound2 = tempitem.usesound;
6890 }
6891 29440 }
6892 29440 }
6893
6894
2/2
✓ Branch 0 taken 19712 times.
✓ Branch 1 taken 9728 times.
29440 if ( s_version >= 26 ) //! New itemdata vars for weapon editor. -Z
6895 { // temp.useweapon, temp.usedefence, temp.weaprange, temp.weap_pattern[ITEM_MOVEMENT_PATTERNS]
6896
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9728 times.
9728 if(!p_getc(&tempitem.useweapon,f))
6897 {
6898 return qe_invalid;
6899 }
6900
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9728 times.
9728 if(!p_getc(&tempitem.usedefence,f))
6901 {
6902 return qe_invalid;
6903 }
6904
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9728 times.
9728 if(!p_igetl(&tempitem.weaprange,f))
6905 {
6906 return qe_invalid;
6907 }
6908
1/2
✓ Branch 0 taken 9728 times.
✗ Branch 1 not taken.
9728 if(!p_igetl(&tempitem.weapduration,f))
6909 {
6910 return qe_invalid;
6911 }
6912
2/2
✓ Branch 0 taken 97280 times.
✓ Branch 1 taken 9728 times.
107008 for ( int32_t q = 0; q < ITEM_MOVEMENT_PATTERNS; q++ )
6913 {
6914
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 97280 times.
97280 if(!p_igetl(&tempitem.weap_pattern[q],f))
6915 {
6916 return qe_invalid;
6917 }
6918 97280 }
6919 9728 }
6920
6921
2/2
✓ Branch 0 taken 19712 times.
✓ Branch 1 taken 9728 times.
29440 if ( s_version >= 27 ) //! New itemdata vars for weapon editor. -Z
6922 { // temp.useweapon, temp.usedefence, temp.weaprange, temp.weap_pattern[ITEM_MOVEMENT_PATTERNS]
6923
1/2
✓ Branch 0 taken 9728 times.
✗ Branch 1 not taken.
9728 if(!p_igetl(&tempitem.duplicates,f))
6924 {
6925 return qe_invalid;
6926 }
6927
2/2
✓ Branch 0 taken 77824 times.
✓ Branch 1 taken 9728 times.
87552 for ( int32_t q = 0; q < INITIAL_D; q++ )
6928 {
6929
1/2
✓ Branch 0 taken 77824 times.
✗ Branch 1 not taken.
77824 if(!p_igetl(&tempitem.weap_initiald[q],f))
6930 {
6931 return qe_invalid;
6932 }
6933 77824 }
6934
2/2
✓ Branch 0 taken 19456 times.
✓ Branch 1 taken 9728 times.
29184 for ( int32_t q = 0; q < INITIAL_A; q++ )
6935 {
6936
1/2
✓ Branch 0 taken 19456 times.
✗ Branch 1 not taken.
19456 if(!p_getc(&tempitem.weap_initiala[q],f))
6937 {
6938 return qe_invalid;
6939 }
6940 19456 }
6941
6942
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9728 times.
9728 if(!p_getc(&tempitem.drawlayer,f))
6943 {
6944 return qe_invalid;
6945 }
6946
6947
6948
1/2
✓ Branch 0 taken 9728 times.
✗ Branch 1 not taken.
9728 if(!p_igetl(&tempitem.hxofs,f))
6949 {
6950 return qe_invalid;
6951 }
6952
1/2
✓ Branch 0 taken 9728 times.
✗ Branch 1 not taken.
9728 if(!p_igetl(&tempitem.hyofs,f))
6953 {
6954 return qe_invalid;
6955 }
6956
1/2
✓ Branch 0 taken 9728 times.
✗ Branch 1 not taken.
9728 if(!p_igetl(&tempitem.hxsz,f))
6957 {
6958 return qe_invalid;
6959 }
6960
1/2
✓ Branch 0 taken 9728 times.
✗ Branch 1 not taken.
9728 if(!p_igetl(&tempitem.hysz,f))
6961 {
6962 return qe_invalid;
6963 }
6964
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9728 times.
9728 if(!p_igetl(&tempitem.hzsz,f))
6965 {
6966 return qe_invalid;
6967 }
6968
1/2
✓ Branch 0 taken 9728 times.
✗ Branch 1 not taken.
9728 if(!p_igetl(&tempitem.xofs,f))
6969 {
6970 return qe_invalid;
6971 }
6972
1/2
✓ Branch 0 taken 9728 times.
✗ Branch 1 not taken.
9728 if(!p_igetl(&tempitem.yofs,f))
6973 {
6974 return qe_invalid;
6975 }
6976
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9728 times.
9728 if(!p_igetl(&tempitem.weap_hxofs,f))
6977 {
6978 return qe_invalid;
6979 }
6980
1/2
✓ Branch 0 taken 9728 times.
✗ Branch 1 not taken.
9728 if(!p_igetl(&tempitem.weap_hyofs,f))
6981 {
6982 return qe_invalid;
6983 }
6984
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9728 times.
9728 if(!p_igetl(&tempitem.weap_hxsz,f))
6985 {
6986 return qe_invalid;
6987 }
6988
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9728 times.
9728 if(!p_igetl(&tempitem.weap_hysz,f))
6989 {
6990 return qe_invalid;
6991 }
6992
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9728 times.
9728 if(!p_igetl(&tempitem.weap_hzsz,f))
6993 {
6994 return qe_invalid;
6995 }
6996
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9728 times.
9728 if(!p_igetl(&tempitem.weap_xofs,f))
6997 {
6998 return qe_invalid;
6999 }
7000
1/2
✓ Branch 0 taken 9728 times.
✗ Branch 1 not taken.
9728 if(!p_igetl(&tempitem.weap_yofs,f))
7001 {
7002 return qe_invalid;
7003 }
7004
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9728 times.
9728 if(!p_igetw(&tempitem.weaponscript,f))
7005 {
7006 return qe_invalid;
7007 }
7008
1/2
✓ Branch 0 taken 9728 times.
✗ Branch 1 not taken.
9728 if(!p_igetl(&tempitem.wpnsprite,f))
7009 {
7010 return qe_invalid;
7011 }
7012 9728 auto num_cost_tmr = (s_version > 52 ? 2 : 1);
7013
2/2
✓ Branch 0 taken 19456 times.
✓ Branch 1 taken 9728 times.
29184 for(auto q = 0; q < num_cost_tmr; ++q)
7014 {
7015
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 19456 times.
19456 if(!p_igetl(&tempitem.magiccosttimer[q],f))
7016 {
7017 return qe_invalid;
7018 }
7019 19456 }
7020
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9728 times.
9728 for(auto q = num_cost_tmr; q < 2; ++q)
7021 tempitem.magiccosttimer[q] = 0;
7022 9728 }
7023
2/2
✓ Branch 0 taken 19712 times.
✓ Branch 1 taken 9728 times.
29440 if ( s_version >= 28 ) //! New itemdata vars for weapon editor. -Z
7024 {
7025 //Item Size FLags, TileWidth, TileHeight
7026
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9728 times.
9728 if(!p_igetl(&tempitem.overrideFLAGS,f))
7027 {
7028 return qe_invalid;
7029 }
7030
1/2
✓ Branch 0 taken 9728 times.
✗ Branch 1 not taken.
9728 if(!p_igetl(&tempitem.tilew,f))
7031 {
7032 return qe_invalid;
7033 }
7034
1/2
✓ Branch 0 taken 9728 times.
✗ Branch 1 not taken.
9728 if(!p_igetl(&tempitem.tileh,f))
7035 {
7036 return qe_invalid;
7037 }
7038 9728 }
7039
2/2
✓ Branch 0 taken 19712 times.
✓ Branch 1 taken 9728 times.
29440 if ( s_version >= 29 ) //! More new vars.
7040 {
7041 //Item Size FLags, TileWidth, TileHeight
7042
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9728 times.
9728 if(!p_igetl(&tempitem.weapoverrideFLAGS,f))
7043 {
7044 return qe_invalid;
7045 }
7046
1/2
✓ Branch 0 taken 9728 times.
✗ Branch 1 not taken.
9728 if(!p_igetl(&tempitem.weap_tilew,f))
7047 {
7048 return qe_invalid;
7049 }
7050
1/2
✓ Branch 0 taken 9728 times.
✗ Branch 1 not taken.
9728 if(!p_igetl(&tempitem.weap_tileh,f))
7051 {
7052 return qe_invalid;
7053 }
7054 9728 }
7055
2/2
✓ Branch 0 taken 19712 times.
✓ Branch 1 taken 9728 times.
29440 if ( s_version >= 30 ) //! More new vars.
7056 {
7057 //Pickup Type
7058
1/2
✓ Branch 0 taken 9728 times.
✗ Branch 1 not taken.
9728 if(!p_igetl(&tempitem.pickup,f))
7059 {
7060 return qe_invalid;
7061 }
7062 9728 }
7063
2/2
✓ Branch 0 taken 19712 times.
✓ Branch 1 taken 9728 times.
29440 if ( s_version >= 32 ) //! More new vars.
7064 {
7065 //Pickup Type
7066
1/2
✓ Branch 0 taken 9728 times.
✗ Branch 1 not taken.
9728 if(!p_igetw(&tempitem.pstring,f))
7067 {
7068 return qe_invalid;
7069 }
7070 9728 }
7071
2/2
✓ Branch 0 taken 19712 times.
✓ Branch 1 taken 9728 times.
29440 if ( s_version >= 33 ) //! More new vars.
7072 {
7073 //Pickup Type
7074
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9728 times.
9728 if(!p_igetw(&tempitem.pickup_string_flags,f))
7075 {
7076 return qe_invalid;
7077 }
7078 9728 }
7079
2/2
✓ Branch 0 taken 19712 times.
✓ Branch 1 taken 9728 times.
29440 if ( s_version >= 34 ) //! cost counter
7080 {
7081
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9728 times.
9728 if(s_version < 53)
7082 {
7083 if(!p_getc(&tempitem.cost_counter[0],f))
7084 {
7085 return qe_invalid;
7086 }
7087 }
7088 else
7089 {
7090
2/2
✓ Branch 0 taken 19456 times.
✓ Branch 1 taken 9728 times.
29184 for(auto q = 0; q < 2; ++q)
7091 {
7092
1/2
✓ Branch 0 taken 19456 times.
✗ Branch 1 not taken.
19456 if(!p_getc(&tempitem.cost_counter[q],f))
7093 {
7094 return qe_invalid;
7095 }
7096 19456 }
7097 }
7098 9728 }
7099
2/2
✓ Branch 0 taken 19712 times.
✓ Branch 1 taken 9728 times.
29440 if ( s_version >= 44 ) //! sprite scripts
7100 {
7101
2/2
✓ Branch 0 taken 77824 times.
✓ Branch 1 taken 9728 times.
87552 for ( int32_t q = 0; q < 8; q++ )
7102 {
7103
2/2
✓ Branch 0 taken 5058560 times.
✓ Branch 1 taken 77824 times.
5136384 for ( int32_t w = 0; w < 65; w++ )
7104 {
7105
1/2
✓ Branch 0 taken 5058560 times.
✗ Branch 1 not taken.
5058560 if(!p_getc(&(tempitem.initD_label[q][w]),f))
7106 {
7107 return qe_invalid;
7108 }
7109 5058560 }
7110
2/2
✓ Branch 0 taken 5058560 times.
✓ Branch 1 taken 77824 times.
5136384 for ( int32_t w = 0; w < 65; w++ )
7111 {
7112
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5058560 times.
5058560 if(!p_getc(&(tempitem.weapon_initD_label[q][w]),f))
7113 {
7114 return qe_invalid;
7115 }
7116 5058560 }
7117
2/2
✓ Branch 0 taken 5058560 times.
✓ Branch 1 taken 77824 times.
5136384 for ( int32_t w = 0; w < 65; w++ )
7118 {
7119
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5058560 times.
5058560 if(!p_getc(&(tempitem.sprite_initD_label[q][w]),f))
7120 {
7121 return qe_invalid;
7122 }
7123 5058560 }
7124
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 77824 times.
77824 if(!p_igetl(&(tempitem.sprite_initiald[q]),f))
7125 {
7126 return qe_invalid;
7127 }
7128
7129 77824 }
7130
2/2
✓ Branch 0 taken 19456 times.
✓ Branch 1 taken 9728 times.
29184 for ( int32_t q = 0; q < 2; q++ )
7131 {
7132
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 19456 times.
19456 if(!p_getc(&(tempitem.sprite_initiala[q]),f))
7133 {
7134 return qe_invalid;
7135 }
7136 19456 }
7137 //Pickup Type
7138
1/2
✓ Branch 0 taken 9728 times.
✗ Branch 1 not taken.
9728 if(!p_igetw(&tempitem.sprite_script,f))
7139 {
7140 return qe_invalid;
7141 }
7142 9728 }
7143
2/2
✓ Branch 0 taken 19712 times.
✓ Branch 1 taken 9728 times.
29440 if ( s_version >= 48 ) //! pickup flags
7144 {
7145
1/2
✓ Branch 0 taken 9728 times.
✗ Branch 1 not taken.
9728 if(!p_getc(&(tempitem.pickupflag),f))
7146 {
7147 return qe_invalid;
7148 }
7149 9728 }
7150
2/2
✓ Branch 0 taken 21248 times.
✓ Branch 1 taken 8192 times.
29440 if ( s_version >= 57 )
7151 {
7152 8192 std::string str;
7153
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 8192 times.
✓ Branch 2 taken 8192 times.
✗ Branch 3 not taken.
8192 if(!p_getcstr(&str,f))
7154 return qe_invalid;
7155 8192 strncpy(tempitem.display_name,str.c_str(),255);
7156
1/3
✓ Branch 0 taken 8192 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
8192 }
7157 29440 }
7158 else
7159 {
7160 840 tempitem.count=-1;
7161 840 tempitem.family=itype_misc;
7162 840 tempitem.flags=tempitem.wpn=tempitem.wpn2=tempitem.wpn3=tempitem.wpn3=tempitem.pickup_hearts=tempitem.misc1=tempitem.misc2=tempitem.usesound=0;
7163 840 tempitem.playsound=WAV_SCALE;
7164 840 reset_itembuf(&tempitem,i);
7165 }
7166
7167
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30280 times.
30280 if (!should_skip)
7168 {
7169
1/2
✓ Branch 0 taken 30280 times.
✗ Branch 1 not taken.
30280 if(loading_tileset_flags & TILESET_CLEARSCRIPTS)
7170 {
7171 tempitem.script = 0;
7172 tempitem.weaponscript = 0;
7173 for(int q = 0; q < 8; ++q)
7174 {
7175 tempitem.initiald[q] = 0;
7176 tempitem.weap_initiald[q] = 0;
7177 }
7178 }
7179 30280 memcpy(&itemsbuf[i], &tempitem, sizeof(itemdata));
7180 30280 }
7181 30280 }
7182
7183
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 131 times.
131 if (should_skip)
7184 return 0;
7185
7186 //////////////////////////////////////////////////////
7187 // Now do any updates because of new item additions
7188 // (These can't be done above because items_to_read
7189 // might be too low.)
7190 //////////////////////////////////////////////////////
7191
2/2
✓ Branch 0 taken 33536 times.
✓ Branch 1 taken 131 times.
33667 for(int32_t i=0; i<MAXITEMS; i++)
7192 {
7193 33536 memcpy(&tempitem, &itemsbuf[i], sizeof(itemdata));
7194
7195 //Account for older quests that didn't have an actual item for the used letter
7196
4/4
✓ Branch 0 taken 4096 times.
✓ Branch 1 taken 29440 times.
✓ Branch 2 taken 4080 times.
✓ Branch 3 taken 16 times.
33536 if(s_version < 2 && i==iLetterUsed)
7197 {
7198 16 reset_itembuf(&tempitem, iLetterUsed);
7199 16 strcpy(item_string[i],old_item_string[i]);
7200 16 tempitem.tile = itemsbuf[iLetter].tile;
7201 16 tempitem.csets = itemsbuf[iLetter].csets;
7202 16 tempitem.misc_flags = itemsbuf[iLetter].misc_flags;
7203 16 tempitem.frames = itemsbuf[iLetter].frames;
7204 16 tempitem.speed = itemsbuf[iLetter].speed;
7205 16 tempitem.ltm = itemsbuf[iLetter].ltm;
7206 16 }
7207
7208
2/2
✓ Branch 0 taken 29440 times.
✓ Branch 1 taken 4096 times.
33536 if(s_version < 3)
7209 {
7210
3/3
✓ Branch 0 taken 352 times.
✓ Branch 1 taken 3728 times.
✓ Branch 2 taken 16 times.
4096 switch(i)
7211 {
7212 case iRocsFeather:
7213 case iHoverBoots:
7214 case iSpinScroll:
7215 case iL2SpinScroll:
7216 case iCrossScroll:
7217 case iQuakeScroll:
7218 case iL2QuakeScroll:
7219 case iWhispRing:
7220 case iL2WhispRing:
7221 case iChargeRing:
7222 case iL2ChargeRing:
7223 case iPerilScroll:
7224 case iWalletL3:
7225 case iQuiverL4:
7226 case iBombBagL4:
7227 case iBracelet:
7228 case iL2Bracelet:
7229 case iOldGlove:
7230 case iL2Ladder:
7231 case iWealthMedal:
7232 case iL2WealthMedal:
7233 case iL3WealthMedal:
7234 352 reset_itembuf(&tempitem, i);
7235 352 strcpy(item_string[i],old_item_string[i]);
7236 352 break;
7237
7238 case iSShield:
7239 16 reset_itembuf(&tempitem, i);
7240 16 strcpy(item_string[i],old_item_string[i]);
7241 16 strcpy(item_string[iShield],old_item_string[iShield]);
7242 16 strcpy(item_string[iMShield],old_item_string[iMShield]);
7243 16 break;
7244 }
7245 4096 }
7246
7247
2/2
✓ Branch 0 taken 29440 times.
✓ Branch 1 taken 4096 times.
33536 if(s_version < 5)
7248 {
7249
2/2
✓ Branch 0 taken 112 times.
✓ Branch 1 taken 3984 times.
4096 switch(i)
7250 {
7251 case iHeartRing:
7252 case iL2HeartRing:
7253 case iL3HeartRing:
7254 case iMagicRing:
7255 case iL2MagicRing:
7256 case iL3MagicRing:
7257 case iL4MagicRing:
7258 112 reset_itembuf(&tempitem, i);
7259 112 strcpy(item_string[i],old_item_string[i]);
7260 112 break;
7261 }
7262 4096 }
7263
7264
2/2
✓ Branch 0 taken 29440 times.
✓ Branch 1 taken 4096 times.
33536 if(s_version < 6) // April 2007: Advanced item editing capabilities.
7265 {
7266
4/4
✓ Branch 0 taken 4080 times.
✓ Branch 1 taken 16 times.
✓ Branch 2 taken 16 times.
✓ Branch 3 taken 4064 times.
4096 if(i!=iBPotion && i!=iRPotion)
7267 4064 tempitem.flags |= get_bit(deprecated_rules,32) ? ITEM_KEEPOLD : 0;
7268
7269
43/43
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 16 times.
✓ Branch 2 taken 16 times.
✓ Branch 3 taken 16 times.
✓ Branch 4 taken 16 times.
✓ Branch 5 taken 16 times.
✓ Branch 6 taken 64 times.
✓ Branch 7 taken 3376 times.
✓ Branch 8 taken 16 times.
✓ Branch 9 taken 16 times.
✓ Branch 10 taken 16 times.
✓ Branch 11 taken 16 times.
✓ Branch 12 taken 16 times.
✓ Branch 13 taken 16 times.
✓ Branch 14 taken 16 times.
✓ Branch 15 taken 16 times.
✓ Branch 16 taken 16 times.
✓ Branch 17 taken 16 times.
✓ Branch 18 taken 16 times.
✓ Branch 19 taken 16 times.
✓ Branch 20 taken 16 times.
✓ Branch 21 taken 16 times.
✓ Branch 22 taken 16 times.
✓ Branch 23 taken 16 times.
✓ Branch 24 taken 16 times.
✓ Branch 25 taken 16 times.
✓ Branch 26 taken 16 times.
✓ Branch 27 taken 16 times.
✓ Branch 28 taken 16 times.
✓ Branch 29 taken 16 times.
✓ Branch 30 taken 16 times.
✓ Branch 31 taken 16 times.
✓ Branch 32 taken 16 times.
✓ Branch 33 taken 16 times.
✓ Branch 34 taken 16 times.
✓ Branch 35 taken 16 times.
✓ Branch 36 taken 16 times.
✓ Branch 37 taken 16 times.
✓ Branch 38 taken 16 times.
✓ Branch 39 taken 16 times.
✓ Branch 40 taken 16 times.
✓ Branch 41 taken 16 times.
✓ Branch 42 taken 16 times.
4096 switch(i)
7270 {
7271 case iTriforce:
7272 16 tempitem.fam_type=1;
7273 16 break;
7274
7275 case iBigTri:
7276 16 tempitem.fam_type=0;
7277 16 break;
7278
7279 case iBombs:
7280 16 tempitem.fam_type=i_bomb;
7281 16 tempitem.power=4;
7282 16 tempitem.wpn=wBOMB;
7283 16 tempitem.wpn2=wBOOM;
7284 16 tempitem.misc1 = 50;
7285
7286
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if(get_bit(deprecated_rules,qr_SLOWBOMBFUSES_DEP)) tempitem.misc1 = 200;
7287
7288 16 break;
7289
7290 case iSBomb:
7291 16 tempitem.fam_type=i_sbomb;
7292 16 tempitem.power=16;
7293 16 tempitem.wpn=wSBOMB;
7294 16 tempitem.wpn2=wSBOOM;
7295 16 tempitem.misc1 = 50;
7296
7297
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if(get_bit(deprecated_rules,qr_SLOWBOMBFUSES_DEP)) tempitem.misc1 = 400;
7298
7299 16 break;
7300
7301 case iBook:
7302
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if(get_bit(deprecated_rules, qr_FIREMAGICSPRITE_DEP))
7303 tempitem.wpn = wFIREMAGIC;
7304
7305 16 break;
7306
7307 case iSArrow:
7308 16 tempitem.wpn2 = get_bit(deprecated_rules,27) ? wSSPARKLE : 0; //qr_SASPARKLES
7309 16 tempitem.power=4;
7310 16 tempitem.flags|=ITEM_GAMEDATA;
7311 16 tempitem.wpn=wSARROW;
7312 16 break;
7313
7314 case iGArrow:
7315 16 tempitem.wpn2 = get_bit(deprecated_rules,28) ? wGSPARKLE : 0; //qr_GASPARKLES
7316 16 tempitem.power=8;
7317 16 tempitem.flags|=(ITEM_GAMEDATA|ITEM_FLAG1);
7318 16 tempitem.wpn=wGARROW;
7319 16 break;
7320
7321 case iBrang:
7322 16 tempitem.power=0;
7323 16 tempitem.wpn=wBRANG;
7324 16 tempitem.misc1=36;
7325 16 break;
7326
7327 case iMBrang:
7328 16 tempitem.wpn2 = get_bit(deprecated_rules,29) ? wMSPARKLE : 0; //qr_MBSPARKLES
7329 16 tempitem.power=0;
7330 16 tempitem.wpn=wMBRANG;
7331 16 break;
7332
7333 case iFBrang:
7334 16 tempitem.wpn3 = get_bit(deprecated_rules,30) ? wFSPARKLE : 0; //qr_FBSPARKLES
7335 16 tempitem.power=2;
7336 16 tempitem.wpn=wFBRANG;
7337 16 break;
7338
7339 case iBoots:
7340 16 tempitem.cost_amount[0] = get_bit(deprecated_rules,qr_MAGICBOOTS_DEP) ? 1 : 0;
7341 16 tempitem.power=7;
7342 16 break;
7343
7344 case iWand:
7345 16 tempitem.cost_amount[0] = get_bit(deprecated_rules,qr_MAGICWAND_DEP) ? 8 : 0;
7346 16 tempitem.power=2;
7347 16 tempitem.wpn=wWAND;
7348 16 tempitem.wpn3=wMAGIC;
7349 16 break;
7350
7351 case iBCandle:
7352 16 tempitem.cost_amount[0] = get_bit(deprecated_rules,qr_MAGICCANDLE_DEP) ? 4 : 0;
7353 16 tempitem.power=1;
7354 16 tempitem.flags|=(ITEM_GAMEDATA|ITEM_FLAG1);
7355 16 tempitem.wpn3=wFIRE;
7356 16 break;
7357
7358 case iRCandle:
7359 16 tempitem.cost_amount[0] = get_bit(deprecated_rules,qr_MAGICCANDLE_DEP) ? 4 : 0;
7360 16 tempitem.power=1;
7361 16 tempitem.wpn3=wFIRE;
7362 16 break;
7363
7364 case iSword:
7365 16 tempitem.power=1;
7366 16 tempitem.flags|= ITEM_FLAG4 |ITEM_FLAG2;
7367 16 tempitem.wpn=tempitem.wpn3=wSWORD;
7368 16 tempitem.wpn2=wSWORDSLASH;
7369 16 break;
7370
7371 case iWSword:
7372 16 tempitem.power=2;
7373 16 tempitem.flags|= ITEM_FLAG4 |ITEM_FLAG2;
7374 16 tempitem.wpn=tempitem.wpn3=wWSWORD;
7375 16 tempitem.wpn2=wWSWORDSLASH;
7376 16 break;
7377
7378 case iMSword:
7379 16 tempitem.power=4;
7380 16 tempitem.flags|= ITEM_FLAG4 |ITEM_FLAG2;
7381 16 tempitem.wpn=tempitem.wpn3=wMSWORD;
7382 16 tempitem.wpn2=wMSWORDSLASH;
7383 16 break;
7384
7385 case iXSword:
7386 16 tempitem.power=8;
7387 16 tempitem.flags|= ITEM_FLAG4 |ITEM_FLAG2;
7388 16 tempitem.wpn=tempitem.wpn3=wXSWORD;
7389 16 tempitem.wpn2=wXSWORDSLASH;
7390 16 break;
7391
7392 case iDivineProtection:
7393 16 tempitem.flags |= get_bit(deprecated_rules,qr_FLICKERINGDIVINEPROTECTIONROCKET_DEP) ? ITEM_FLAG1 : 0;
7394 16 tempitem.flags |= get_bit(deprecated_rules,qr_TRANSLUCENTDIVINEPROTECTIONROCKET_DEP) ? ITEM_FLAG2 : 0;
7395 16 tempitem.wpn=wDIVINEPROTECTION1A;
7396 16 tempitem.wpn2=wDIVINEPROTECTION1B;
7397 16 tempitem.wpn3=wDIVINEPROTECTIONS1A;
7398 16 tempitem.wpn4=wDIVINEPROTECTIONS1B;
7399 16 tempitem.wpn6=wDIVINEPROTECTION2A;
7400 16 tempitem.wpn7=wDIVINEPROTECTION2B;
7401 16 tempitem.wpn8=wDIVINEPROTECTIONS2A;
7402 16 tempitem.wpn9=wDIVINEPROTECTIONS2B;
7403 16 tempitem.wpn5 = iwDivineProtectionShieldFront;
7404 16 tempitem.wpn10 = iwDivineProtectionShieldBack;
7405 16 tempitem.misc1=512;
7406 16 tempitem.cost_amount[0]=64;
7407 16 break;
7408
7409 case iLens:
7410 16 tempitem.misc1=60;
7411 16 tempitem.flags |= get_qr(qr_ENABLEMAGIC) ? 0 : ITEM_RUPEE_MAGIC;
7412 16 tempitem.cost_amount[0] = get_qr(qr_ENABLEMAGIC) ? 2 : 1;
7413 16 break;
7414
7415 case iArrow:
7416 16 tempitem.power=2;
7417 16 tempitem.wpn=wARROW;
7418 16 break;
7419
7420 case iHoverBoots:
7421 16 tempitem.misc1=45;
7422 16 tempitem.wpn=iwHover;
7423 16 break;
7424
7425 case iDivineFire:
7426 16 tempitem.power=8;
7427 16 tempitem.wpn=wDIVINEFIRE1A;
7428 16 tempitem.wpn2=wDIVINEFIRE1B;
7429 16 tempitem.wpn3=wDIVINEFIRES1A;
7430 16 tempitem.wpn4=wDIVINEFIRES1B;
7431 16 tempitem.misc1 = 32;
7432 16 tempitem.misc2 = 200;
7433 16 tempitem.cost_amount[0]=32;
7434 16 break;
7435
7436 case iDivineEscape:
7437 16 tempitem.cost_amount[0]=32;
7438 16 break;
7439
7440 case iHookshot:
7441 16 tempitem.power=0;
7442 16 tempitem.flags&=~ITEM_FLAG1;
7443 16 tempitem.wpn=wHSHEAD;
7444 16 tempitem.wpn2=wHSCHAIN_H;
7445 16 tempitem.wpn4=wHSHANDLE;
7446 16 tempitem.wpn3=wHSCHAIN_V;
7447 16 tempitem.misc1=50;
7448 16 tempitem.misc2=100;
7449 16 break;
7450
7451 case iLongshot:
7452 16 tempitem.power=0;
7453 16 tempitem.flags&=~ITEM_FLAG1;
7454 16 tempitem.wpn=wLSHEAD;
7455 16 tempitem.wpn2=wLSCHAIN_H;
7456 16 tempitem.wpn4=wLSHANDLE;
7457 16 tempitem.wpn3=wLSCHAIN_V;
7458 16 tempitem.misc1=99;
7459 16 tempitem.misc2=100;
7460 16 break;
7461
7462 case iHammer:
7463 16 tempitem.power=4;
7464 16 tempitem.wpn=wHAMMER;
7465 16 tempitem.wpn2=iwHammerSmack;
7466 16 break;
7467
7468 case iCByrna:
7469 16 tempitem.power=1;
7470 16 tempitem.wpn=wCBYRNA;
7471 16 tempitem.wpn2=wCBYRNASLASH;
7472 16 tempitem.wpn3=wCBYRNAORB;
7473 16 tempitem.misc1=4;
7474 16 tempitem.misc2=16;
7475 16 tempitem.misc3=1;
7476 16 tempitem.cost_amount[0]=1;
7477 16 break;
7478
7479 case iWhistle:
7480 16 tempitem.wpn=wWIND;
7481 16 tempitem.misc1=3;
7482 16 tempitem.flags|=ITEM_FLAG1;
7483 16 break;
7484
7485 case iBRing:
7486 16 tempitem.power=2;
7487 16 tempitem.misc1=spBLUE;
7488 16 break;
7489
7490 case iRRing:
7491 16 tempitem.power=4;
7492 16 tempitem.misc1=spRED;
7493 16 break;
7494
7495 case iGRing:
7496 16 tempitem.power=8;
7497 16 tempitem.misc1=spGOLD;
7498 16 break;
7499
7500 case iSpinScroll:
7501 16 tempitem.power = 2;
7502 16 tempitem.misc1 = 1;
7503 16 break;
7504
7505 case iL2SpinScroll:
7506 16 tempitem.family=itype_spinscroll2;
7507 16 tempitem.fam_type=1;
7508 16 tempitem.cost_amount[0]=8;
7509 16 tempitem.power=2;
7510 16 tempitem.misc1 = 20;
7511 16 break;
7512
7513 case iQuakeScroll:
7514 16 tempitem.misc1=0x10;
7515 16 tempitem.misc2=64;
7516 16 break;
7517
7518 case iL2QuakeScroll:
7519 16 tempitem.family=itype_quakescroll2;
7520 16 tempitem.fam_type=1;
7521 16 tempitem.power = 2;
7522 16 tempitem.misc1=0x20;
7523 16 tempitem.misc2=192;
7524 16 tempitem.cost_amount[0]=8;
7525 16 break;
7526
7527 case iChargeRing:
7528 16 tempitem.misc1=64;
7529 16 tempitem.misc2=128;
7530 16 break;
7531
7532 case iL2ChargeRing:
7533 16 tempitem.misc1=32;
7534 16 tempitem.misc2=64;
7535 16 break;
7536
7537 case iOldGlove:
7538 16 tempitem.flags |= ITEM_FLAG1;
7539
7540 //fallthrough
7541 case iBombBagL4:
7542 case iWalletL3:
7543 case iQuiverL4:
7544 case iBracelet:
7545 80 tempitem.power = 1;
7546 80 break;
7547
7548 case iL2Bracelet:
7549 16 tempitem.power = 2;
7550 16 break;
7551
7552 case iMKey:
7553 16 tempitem.power=0xFF;
7554 16 tempitem.flags |= ITEM_FLAG1;
7555 16 break;
7556 }
7557 4096 }
7558
7559
2/2
✓ Branch 0 taken 29440 times.
✓ Branch 1 taken 4096 times.
33536 if(s_version < 7)
7560 {
7561
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 4032 times.
4096 switch(i)
7562 {
7563 case iStoneAgony:
7564 case iStompBoots:
7565 case iPerilRing:
7566 case iWhimsicalRing:
7567 {
7568 64 reset_itembuf(&tempitem, i);
7569 64 strcpy(item_string[i],old_item_string[i]);
7570 64 break;
7571 }
7572 }
7573 4096 }
7574
7575
2/2
✓ Branch 0 taken 29440 times.
✓ Branch 1 taken 4096 times.
33536 if(s_version < 8) // May 2007: Some corrections.
7576 {
7577
7/7
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 16 times.
✓ Branch 2 taken 48 times.
✓ Branch 3 taken 3968 times.
✓ Branch 4 taken 16 times.
✓ Branch 5 taken 16 times.
✓ Branch 6 taken 16 times.
4096 switch(i)
7578 {
7579 case iMShield:
7580 16 tempitem.misc1|=shFLAME;
7581 16 tempitem.misc2|=shFIREBALL|shMAGIC;
7582
7583
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(get_qr(qr_SWORDMIRROR))
7584 {
7585 tempitem.misc2 |= shSWORD;
7586 }
7587
7588 // fallthrough
7589 case iShield:
7590 32 tempitem.misc1|=shFIREBALL|shSWORD|shMAGIC;
7591
7592 // fallthrough
7593 case iSShield:
7594 48 tempitem.misc1|=shROCK|shARROW|shBRANG|shSCRIPT;
7595
7596
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
48 if(get_bit(deprecated_rules,102)) //qr_REFLECTROCKS
7597 {
7598 tempitem.misc2 |= shROCK;
7599 }
7600
7601 48 break;
7602
7603 case iWhispRing:
7604 16 tempitem.power=1;
7605 16 tempitem.flags|=ITEM_GAMEDATA|ITEM_FLAG1;
7606 16 tempitem.misc1 = 3;
7607 16 break;
7608
7609 case iL2WhispRing:
7610 16 tempitem.power=0;
7611 16 tempitem.flags|=ITEM_GAMEDATA|ITEM_FLAG1;
7612 16 tempitem.misc1 = 3;
7613 16 break;
7614
7615 case iL2Ladder:
7616 case iBow:
7617 case iCByrna:
7618 48 tempitem.power = 1;
7619 48 break;
7620 }
7621 4096 }
7622
7623
4/4
✓ Branch 0 taken 4096 times.
✓ Branch 1 taken 29440 times.
✓ Branch 2 taken 4080 times.
✓ Branch 3 taken 16 times.
33536 if(s_version < 9 && i==iClock)
7624 {
7625 16 tempitem.misc1 = get_bit(deprecated_rules, qr_TEMPCLOCKS_DEP) ? 256 : 0;
7626 16 }
7627
7628 //add the misc flag for bomb
7629
4/4
✓ Branch 0 taken 4096 times.
✓ Branch 1 taken 29440 times.
✓ Branch 2 taken 4080 times.
✓ Branch 3 taken 16 times.
33536 if(s_version < 10 && tempitem.family == itype_bomb)
7630 {
7631 16 tempitem.flags = (tempitem.flags & ~ITEM_FLAG1) | (get_qr(qr_LONGBOMBBOOM_DEP) ? ITEM_FLAG1 : 0);
7632 16 }
7633
7634
4/4
✓ Branch 0 taken 4096 times.
✓ Branch 1 taken 29440 times.
✓ Branch 2 taken 4064 times.
✓ Branch 3 taken 32 times.
33536 if(s_version < 11 && tempitem.family == itype_triforcepiece)
7635 {
7636 32 tempitem.flags = (tempitem.fam_type ? ITEM_GAMEDATA : 0);
7637 32 tempitem.playsound = (tempitem.fam_type ? WAV_SCALE : WAV_CLEARED);
7638 32 }
7639
7640
2/2
✓ Branch 0 taken 29440 times.
✓ Branch 1 taken 4096 times.
33536 if(s_version < 12) // June 2007: More Misc. attributes.
7641 {
7642
5/5
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 4016 times.
✓ Branch 2 taken 16 times.
✓ Branch 3 taken 16 times.
✓ Branch 4 taken 16 times.
4096 switch(i)
7643 {
7644 case iFBrang:
7645 16 tempitem.misc4 |= shFIREBALL|shSWORD|shMAGIC;
7646
7647 //fallthrough
7648 case iMBrang:
7649 32 tempitem.misc3 |= shSWORD|shMAGIC;
7650
7651 //fallthrough
7652 case iHookshot:
7653 case iLongshot:
7654 //fallthrough
7655 64 tempitem.misc3 |= shFIREBALL;
7656
7657 case iBrang:
7658 80 tempitem.misc3 |= shBRANG|shROCK|shARROW;
7659 80 break;
7660 }
7661
7662
16/16
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 48 times.
✓ Branch 2 taken 16 times.
✓ Branch 3 taken 16 times.
✓ Branch 4 taken 16 times.
✓ Branch 5 taken 64 times.
✓ Branch 6 taken 32 times.
✓ Branch 7 taken 1956 times.
✓ Branch 8 taken 16 times.
✓ Branch 9 taken 16 times.
✓ Branch 10 taken 32 times.
✓ Branch 11 taken 48 times.
✓ Branch 12 taken 48 times.
✓ Branch 13 taken 1740 times.
✓ Branch 14 taken 16 times.
✓ Branch 15 taken 16 times.
4096 switch(tempitem.family)
7663 {
7664 case itype_hoverboots:
7665 16 tempitem.usesound = WAV_ZN1HOVER;
7666 16 break;
7667
7668 case itype_wand:
7669 16 tempitem.usesound = WAV_WAND;
7670 16 break;
7671
7672 case itype_book:
7673 16 tempitem.usesound = WAV_FIRE;
7674 16 break;
7675
7676 case itype_arrow:
7677 48 tempitem.usesound = WAV_ARROW;
7678 48 break;
7679
7680 case itype_hookshot:
7681 32 tempitem.usesound = WAV_HOOKSHOT;
7682 32 break;
7683
7684 case itype_brang:
7685 48 tempitem.usesound = WAV_BRANG;
7686 48 break;
7687
7688 case itype_shield:
7689 48 tempitem.usesound = WAV_CHINK;
7690 48 break;
7691
7692 case itype_sword:
7693 1740 tempitem.usesound = WAV_SWORD;
7694 1740 break;
7695
7696 case itype_whistle:
7697 16 tempitem.usesound = WAV_WHISTLE;
7698 16 break;
7699
7700 case itype_hammer:
7701 16 tempitem.usesound = WAV_HAMMER;
7702 16 break;
7703
7704 case itype_divinefire:
7705 16 tempitem.usesound = WAV_ZN1DIVINEFIRE;
7706 16 break;
7707
7708 case itype_divineescape:
7709 16 tempitem.usesound = WAV_ZN1DIVINEESCAPE;
7710 16 break;
7711
7712 case itype_divineprotection:
7713 16 tempitem.usesound = WAV_ZN1DIVINEPROTECTION1;
7714 16 break;
7715
7716 case itype_bomb:
7717 case itype_sbomb:
7718 case itype_quakescroll:
7719 case itype_quakescroll2:
7720 64 tempitem.usesound = WAV_BOMB;
7721 64 break;
7722
7723 case itype_spinscroll:
7724 case itype_spinscroll2:
7725 32 tempitem.usesound = WAV_ZN1SPINATTACK;
7726 32 break;
7727 }
7728 4096 }
7729
7730
2/2
✓ Branch 0 taken 29440 times.
✓ Branch 1 taken 4096 times.
33536 if(s_version < 13) // July 2007
7731 {
7732
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 4080 times.
4096 if(tempitem.family == itype_whistle)
7733 {
7734 16 tempitem.misc1 = (tempitem.power==2 ? 4 : 3);
7735 16 tempitem.power = 1;
7736 16 tempitem.flags|=ITEM_FLAG1;
7737 16 }
7738
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 4064 times.
4080 else if(tempitem.family == itype_wand)
7739 16 tempitem.flags|=ITEM_FLAG1;
7740
2/2
✓ Branch 0 taken 4048 times.
✓ Branch 1 taken 16 times.
4064 else if(tempitem.family == itype_book)
7741 {
7742 16 tempitem.flags|=ITEM_FLAG1;
7743 16 tempitem.power = 2;
7744 16 }
7745 4096 }
7746
7747
2/2
✓ Branch 0 taken 29440 times.
✓ Branch 1 taken 4096 times.
33536 if(s_version < 14) // August 2007
7748 {
7749
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 4064 times.
4096 if(tempitem.family == itype_fairy)
7750 {
7751 32 tempitem.usesound = WAV_SCALE;
7752
7753
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32 times.
32 if(tempitem.fam_type)
7754 32 tempitem.misc3=50;
7755 32 }
7756
2/2
✓ Branch 0 taken 4032 times.
✓ Branch 1 taken 32 times.
4064 else if(tempitem.family == itype_potion)
7757 {
7758 32 tempitem.flags |= ITEM_GAINOLD;
7759 32 }
7760 4096 }
7761
7762
2/2
✓ Branch 0 taken 29440 times.
✓ Branch 1 taken 4096 times.
33536 if(s_version < 17) // November 2007
7763 {
7764
3/4
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 4064 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 32 times.
4096 if(tempitem.family == itype_candle && !tempitem.wpn3)
7765 {
7766 tempitem.wpn3 = wFIRE;
7767 }
7768
4/4
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 4048 times.
✓ Branch 2 taken 32 times.
✓ Branch 3 taken 16 times.
4096 else if(tempitem.family == itype_arrow && tempitem.power>4)
7769 {
7770 16 tempitem.flags|=ITEM_FLAG1;
7771 16 }
7772 4096 }
7773
7774
2/2
✓ Branch 0 taken 29440 times.
✓ Branch 1 taken 4096 times.
33536 if(s_version < 18) // New Year's Eve 2007
7775 {
7776
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 4080 times.
4096 if(tempitem.family == itype_whistle)
7777 16 tempitem.misc2 = 8; // Use the Whistle warp ring
7778
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 4064 times.
4080 else if(tempitem.family == itype_bait)
7779 16 tempitem.misc1 = 768; // Frames until it goes
7780
2/2
✓ Branch 0 taken 4032 times.
✓ Branch 1 taken 32 times.
4064 else if(tempitem.family == itype_triforcepiece)
7781 {
7782
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 16 times.
32 if(tempitem.flags & ITEM_GAMEDATA)
7783 {
7784 16 tempitem.misc2 = 1; // Cutscene 1
7785 16 tempitem.flags |= ITEM_FLAG1; // Side Warp Out
7786 16 }
7787 32 }
7788 4096 }
7789
7790
2/2
✓ Branch 0 taken 29440 times.
✓ Branch 1 taken 4096 times.
33536 if(s_version < 19) // January 2008
7791 {
7792
2/2
✓ Branch 0 taken 4080 times.
✓ Branch 1 taken 16 times.
4096 if(tempitem.family == itype_divineprotection)
7793 {
7794 16 tempitem.flags |= get_bit(deprecated_rules,qr_NOBOMBPALFLASH+1)?ITEM_FLAG3:0;
7795 16 tempitem.flags |= get_bit(deprecated_rules,qr_NOBOMBPALFLASH+2)?ITEM_FLAG4:0;
7796 16 }
7797 4096 }
7798
7799
2/2
✓ Branch 0 taken 29440 times.
✓ Branch 1 taken 4096 times.
33536 if(s_version < 20) // October 2008
7800 {
7801
2/2
✓ Branch 0 taken 4080 times.
✓ Branch 1 taken 16 times.
4096 if(tempitem.family == itype_divineprotection)
7802 {
7803 16 tempitem.wpn6=wDIVINEPROTECTION2A;
7804 16 tempitem.wpn7=wDIVINEPROTECTION2B;
7805 16 tempitem.wpn8=wDIVINEPROTECTIONS2A;
7806 16 tempitem.wpn9=wDIVINEPROTECTIONS2B;
7807 16 tempitem.wpn5 = iwDivineProtectionShieldFront;
7808 16 tempitem.wpn10 = iwDivineProtectionShieldBack;
7809 16 }
7810 4096 }
7811
7812
2/2
✓ Branch 0 taken 29440 times.
✓ Branch 1 taken 4096 times.
33536 if(s_version < 21) // November 2008
7813 {
7814
1/2
✓ Branch 0 taken 4096 times.
✗ Branch 1 not taken.
4096 if(tempitem.flags & 0x0100) // ITEM_SLASH
7815 {
7816 tempitem.flags &= ~0x0100;
7817
7818 if(tempitem.family == itype_sword ||
7819 tempitem.family == itype_wand ||
7820 tempitem.family == itype_candle ||
7821 tempitem.family == itype_cbyrna)
7822 {
7823 tempitem.flags |= ITEM_FLAG4;
7824 }
7825 }
7826 4096 }
7827
7828
2/2
✓ Branch 0 taken 29440 times.
✓ Branch 1 taken 4096 times.
33536 if(s_version < 22) // September 2009
7829 {
7830
4/4
✓ Branch 0 taken 4080 times.
✓ Branch 1 taken 16 times.
✓ Branch 2 taken 16 times.
✓ Branch 3 taken 4064 times.
4096 if(tempitem.family == itype_sbomb || tempitem.family == itype_bomb)
7831 {
7832 32 tempitem.misc3 = tempitem.power/2;
7833 32 }
7834 4096 }
7835
7836
2/2
✓ Branch 0 taken 29440 times.
✓ Branch 1 taken 4096 times.
33536 if(s_version < 23) // March 2011
7837 {
7838
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 4080 times.
4096 if(tempitem.family == itype_divinefire)
7839 16 tempitem.wpn5 = wFIRE;
7840
2/2
✓ Branch 0 taken 4064 times.
✓ Branch 1 taken 16 times.
4080 else if(tempitem.family == itype_book)
7841 16 tempitem.wpn2 = wFIRE;
7842 4096 }
7843
7844 // Version 25: Bomb bags were acting as though "super bombs also" was checked
7845 // whether it was or not, and a lot of existing quests depended on the
7846 // incorrect behavior.
7847
2/2
✓ Branch 0 taken 29440 times.
✓ Branch 1 taken 4096 times.
33536 if(s_version < 25) // January 2012
7848 {
7849
2/2
✓ Branch 0 taken 4032 times.
✓ Branch 1 taken 64 times.
4096 if(tempitem.family == itype_bombbag)
7850 64 tempitem.flags |= 16;
7851
7852
2/2
✓ Branch 0 taken 4080 times.
✓ Branch 1 taken 16 times.
4096 if(tempitem.family == itype_divinefire)
7853 16 tempitem.flags |= ITEM_FLAG3; // Sideview gravity flag
7854 4096 }
7855
7856
2/2
✓ Branch 0 taken 9728 times.
✓ Branch 1 taken 23808 times.
33536 if( version < 0x254) //Nuke greyed-out flags/values from <=2.53, in case they are used in 2.54/2.55
7857 {
7858
60/60
✓ Branch 0 taken 7811 times.
✓ Branch 1 taken 277 times.
✓ Branch 2 taken 274 times.
✓ Branch 3 taken 222 times.
✓ Branch 4 taken 138 times.
✓ Branch 5 taken 93 times.
✓ Branch 6 taken 184 times.
✓ Branch 7 taken 183 times.
✓ Branch 8 taken 107 times.
✓ Branch 9 taken 302 times.
✓ Branch 10 taken 276 times.
✓ Branch 11 taken 183 times.
✓ Branch 12 taken 283 times.
✓ Branch 13 taken 184 times.
✓ Branch 14 taken 92 times.
✓ Branch 15 taken 184 times.
✓ Branch 16 taken 107 times.
✓ Branch 17 taken 92 times.
✓ Branch 18 taken 279 times.
✓ Branch 19 taken 93 times.
✓ Branch 20 taken 94 times.
✓ Branch 21 taken 184 times.
✓ Branch 22 taken 92 times.
✓ Branch 23 taken 93 times.
✓ Branch 24 taken 92 times.
✓ Branch 25 taken 92 times.
✓ Branch 26 taken 92 times.
✓ Branch 27 taken 107 times.
✓ Branch 28 taken 92 times.
✓ Branch 29 taken 93 times.
✓ Branch 30 taken 92 times.
✓ Branch 31 taken 93 times.
✓ Branch 32 taken 184 times.
✓ Branch 33 taken 368 times.
✓ Branch 34 taken 94 times.
✓ Branch 35 taken 92 times.
✓ Branch 36 taken 168 times.
✓ Branch 37 taken 368 times.
✓ Branch 38 taken 92 times.
✓ Branch 39 taken 92 times.
✓ Branch 40 taken 92 times.
✓ Branch 41 taken 92 times.
✓ Branch 42 taken 92 times.
✓ Branch 43 taken 185 times.
✓ Branch 44 taken 184 times.
✓ Branch 45 taken 92 times.
✓ Branch 46 taken 277 times.
✓ Branch 47 taken 278 times.
✓ Branch 48 taken 372 times.
✓ Branch 49 taken 92 times.
✓ Branch 50 taken 92 times.
✓ Branch 51 taken 92 times.
✓ Branch 52 taken 92 times.
✓ Branch 53 taken 92 times.
✓ Branch 54 taken 93 times.
✓ Branch 55 taken 2541 times.
✓ Branch 56 taken 983 times.
✓ Branch 57 taken 277 times.
✓ Branch 58 taken 1135 times.
✓ Branch 59 taken 2617 times.
23808 switch(tempitem.family)
7859 {
7860 case itype_sword:
7861 {
7862 7811 tempitem.flags &= ~(ITEM_FLAG5);
7863 7811 tempitem.misc3 = 0;
7864 7811 tempitem.misc4 = 0;
7865 7811 tempitem.misc5 = 0;
7866 7811 tempitem.misc6 = 0;
7867 7811 tempitem.misc7 = 0;
7868 7811 tempitem.misc8 = 0;
7869 7811 tempitem.misc9 = 0;
7870 7811 tempitem.misc10 = 0;
7871 7811 tempitem.wpn4 = 0;
7872 7811 tempitem.wpn5 = 0;
7873 7811 tempitem.wpn6 = 0;
7874 7811 tempitem.wpn7 = 0;
7875 7811 tempitem.wpn8 = 0;
7876 7811 tempitem.wpn9 = 0;
7877 7811 tempitem.wpn10 = 0;
7878 7811 break;
7879 }
7880 case itype_brang:
7881 {
7882 277 tempitem.flags &= ~(ITEM_FLAG4 | ITEM_FLAG5);
7883 277 tempitem.misc2 = 0;
7884 277 tempitem.misc5 = 0;
7885 277 tempitem.misc6 = 0;
7886 277 tempitem.misc7 = 0;
7887 277 tempitem.misc8 = 0;
7888 277 tempitem.misc9 = 0;
7889 277 tempitem.misc10 = 0;
7890 277 tempitem.wpn4 = 0;
7891 277 tempitem.wpn5 = 0;
7892 277 tempitem.wpn6 = 0;
7893 277 tempitem.wpn7 = 0;
7894 277 tempitem.wpn8 = 0;
7895 277 tempitem.wpn9 = 0;
7896 277 tempitem.wpn10 = 0;
7897 277 break;
7898 }
7899 case itype_arrow:
7900 {
7901 274 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
7902 274 tempitem.misc2 = 0;
7903 274 tempitem.misc3 = 0;
7904 274 tempitem.misc4 = 0;
7905 274 tempitem.misc5 = 0;
7906 274 tempitem.misc6 = 0;
7907 274 tempitem.misc7 = 0;
7908 274 tempitem.misc8 = 0;
7909 274 tempitem.misc9 = 0;
7910 274 tempitem.misc10 = 0;
7911 274 tempitem.wpn4 = 0;
7912 274 tempitem.wpn5 = 0;
7913 274 tempitem.wpn6 = 0;
7914 274 tempitem.wpn7 = 0;
7915 274 tempitem.wpn8 = 0;
7916 274 tempitem.wpn9 = 0;
7917 274 tempitem.wpn10 = 0;
7918 274 break;
7919 }
7920 case itype_candle:
7921 {
7922 222 tempitem.flags &= ~ (ITEM_FLAG3 | ITEM_FLAG5);
7923 222 tempitem.misc1 = 0;
7924 222 tempitem.misc2 = 0;
7925 222 tempitem.misc3 = 0;
7926 222 tempitem.misc4 = 0;
7927 222 tempitem.misc5 = 0;
7928 222 tempitem.misc6 = 0;
7929 222 tempitem.misc7 = 0;
7930 222 tempitem.misc8 = 0;
7931 222 tempitem.misc9 = 0;
7932 222 tempitem.misc10 = 0;
7933 222 tempitem.wpn4 = 0;
7934 222 tempitem.wpn5 = 0;
7935 222 tempitem.wpn6 = 0;
7936 222 tempitem.wpn7 = 0;
7937 222 tempitem.wpn8 = 0;
7938 222 tempitem.wpn9 = 0;
7939 222 tempitem.wpn10 = 0;
7940 222 break;
7941 }
7942 case itype_whistle:
7943 {
7944 138 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
7945 138 tempitem.misc3 = 0;
7946 138 tempitem.misc4 = 0;
7947 138 tempitem.misc5 = 0;
7948 138 tempitem.misc6 = 0;
7949 138 tempitem.misc7 = 0;
7950 138 tempitem.misc8 = 0;
7951 138 tempitem.misc9 = 0;
7952 138 tempitem.misc10 = 0;
7953 138 tempitem.wpn2 = 0;
7954 138 tempitem.wpn3 = 0;
7955 138 tempitem.wpn4 = 0;
7956 138 tempitem.wpn5 = 0;
7957 138 tempitem.wpn6 = 0;
7958 138 tempitem.wpn7 = 0;
7959 138 tempitem.wpn8 = 0;
7960 138 tempitem.wpn9 = 0;
7961 138 tempitem.wpn10 = 0;
7962 138 break;
7963 }
7964 case itype_bait:
7965 {
7966 93 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
7967 93 tempitem.misc2 = 0;
7968 93 tempitem.misc3 = 0;
7969 93 tempitem.misc4 = 0;
7970 93 tempitem.misc5 = 0;
7971 93 tempitem.misc6 = 0;
7972 93 tempitem.misc7 = 0;
7973 93 tempitem.misc8 = 0;
7974 93 tempitem.misc9 = 0;
7975 93 tempitem.misc10 = 0;
7976 93 tempitem.wpn2 = 0;
7977 93 tempitem.wpn3 = 0;
7978 93 tempitem.wpn4 = 0;
7979 93 tempitem.wpn5 = 0;
7980 93 tempitem.wpn6 = 0;
7981 93 tempitem.wpn7 = 0;
7982 93 tempitem.wpn8 = 0;
7983 93 tempitem.wpn9 = 0;
7984 93 tempitem.wpn10 = 0;
7985 93 break;
7986 }
7987 case itype_letter:
7988 {
7989 184 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
7990 184 tempitem.misc1 = 0;
7991 184 tempitem.misc2 = 0;
7992 184 tempitem.misc3 = 0;
7993 184 tempitem.misc4 = 0;
7994 184 tempitem.misc5 = 0;
7995 184 tempitem.misc6 = 0;
7996 184 tempitem.misc7 = 0;
7997 184 tempitem.misc8 = 0;
7998 184 tempitem.misc9 = 0;
7999 184 tempitem.misc10 = 0;
8000 184 tempitem.wpn = 0;
8001 184 tempitem.wpn2 = 0;
8002 184 tempitem.wpn3 = 0;
8003 184 tempitem.wpn4 = 0;
8004 184 tempitem.wpn5 = 0;
8005 184 tempitem.wpn6 = 0;
8006 184 tempitem.wpn7 = 0;
8007 184 tempitem.wpn8 = 0;
8008 184 tempitem.wpn9 = 0;
8009 184 tempitem.wpn10 = 0;
8010 184 break;
8011 }
8012 case itype_potion:
8013 {
8014 183 tempitem.flags &= ~ (ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8015 183 tempitem.misc3 = 0;
8016 183 tempitem.misc4 = 0;
8017 183 tempitem.misc5 = 0;
8018 183 tempitem.misc6 = 0;
8019 183 tempitem.misc7 = 0;
8020 183 tempitem.misc8 = 0;
8021 183 tempitem.misc9 = 0;
8022 183 tempitem.misc10 = 0;
8023 183 tempitem.wpn = 0;
8024 183 tempitem.wpn2 = 0;
8025 183 tempitem.wpn3 = 0;
8026 183 tempitem.wpn4 = 0;
8027 183 tempitem.wpn5 = 0;
8028 183 tempitem.wpn6 = 0;
8029 183 tempitem.wpn7 = 0;
8030 183 tempitem.wpn8 = 0;
8031 183 tempitem.wpn9 = 0;
8032 183 tempitem.wpn10 = 0;
8033 183 break;
8034 }
8035 case itype_wand:
8036 {
8037 107 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG5);
8038 107 tempitem.misc1 = 0;
8039 107 tempitem.misc2 = 0;
8040 107 tempitem.misc3 = 0;
8041 107 tempitem.misc4 = 0;
8042 107 tempitem.misc5 = 0;
8043 107 tempitem.misc6 = 0;
8044 107 tempitem.misc7 = 0;
8045 107 tempitem.misc8 = 0;
8046 107 tempitem.misc9 = 0;
8047 107 tempitem.misc10 = 0;
8048 107 tempitem.wpn4 = 0;
8049 107 tempitem.wpn5 = 0;
8050 107 tempitem.wpn6 = 0;
8051 107 tempitem.wpn7 = 0;
8052 107 tempitem.wpn8 = 0;
8053 107 tempitem.wpn9 = 0;
8054 107 tempitem.wpn10 = 0;
8055 107 break;
8056 }
8057 case itype_ring:
8058 {
8059 302 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8060 302 tempitem.misc2 = 0;
8061 302 tempitem.misc3 = 0;
8062 302 tempitem.misc4 = 0;
8063 302 tempitem.misc5 = 0;
8064 302 tempitem.misc6 = 0;
8065 302 tempitem.misc7 = 0;
8066 302 tempitem.misc8 = 0;
8067 302 tempitem.misc9 = 0;
8068 302 tempitem.misc10 = 0;
8069 302 tempitem.wpn = 0;
8070 302 tempitem.wpn2 = 0;
8071 302 tempitem.wpn3 = 0;
8072 302 tempitem.wpn4 = 0;
8073 302 tempitem.wpn5 = 0;
8074 302 tempitem.wpn6 = 0;
8075 302 tempitem.wpn7 = 0;
8076 302 tempitem.wpn8 = 0;
8077 302 tempitem.wpn9 = 0;
8078 302 tempitem.wpn10 = 0;
8079 302 break;
8080 }
8081 case itype_wallet:
8082 {
8083 276 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8084 276 tempitem.misc3 = 0;
8085 276 tempitem.misc4 = 0;
8086 276 tempitem.misc5 = 0;
8087 276 tempitem.misc6 = 0;
8088 276 tempitem.misc7 = 0;
8089 276 tempitem.misc8 = 0;
8090 276 tempitem.misc9 = 0;
8091 276 tempitem.misc10 = 0;
8092 276 tempitem.wpn = 0;
8093 276 tempitem.wpn2 = 0;
8094 276 tempitem.wpn3 = 0;
8095 276 tempitem.wpn4 = 0;
8096 276 tempitem.wpn5 = 0;
8097 276 tempitem.wpn6 = 0;
8098 276 tempitem.wpn7 = 0;
8099 276 tempitem.wpn8 = 0;
8100 276 tempitem.wpn9 = 0;
8101 276 tempitem.wpn10 = 0;
8102 276 break;
8103 }
8104 case itype_amulet:
8105 {
8106 183 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8107 183 tempitem.misc1 = 0;
8108 183 tempitem.misc2 = 0;
8109 183 tempitem.misc3 = 0;
8110 183 tempitem.misc4 = 0;
8111 183 tempitem.misc5 = 0;
8112 183 tempitem.misc6 = 0;
8113 183 tempitem.misc7 = 0;
8114 183 tempitem.misc8 = 0;
8115 183 tempitem.misc9 = 0;
8116 183 tempitem.misc10 = 0;
8117 183 tempitem.wpn = 0;
8118 183 tempitem.wpn2 = 0;
8119 183 tempitem.wpn3 = 0;
8120 183 tempitem.wpn4 = 0;
8121 183 tempitem.wpn5 = 0;
8122 183 tempitem.wpn6 = 0;
8123 183 tempitem.wpn7 = 0;
8124 183 tempitem.wpn8 = 0;
8125 183 tempitem.wpn9 = 0;
8126 183 tempitem.wpn10 = 0;
8127 183 break;
8128 }
8129 case itype_shield:
8130 {
8131 283 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8132 283 tempitem.misc3 = 0;
8133 283 tempitem.misc4 = 0;
8134 283 tempitem.misc5 = 0;
8135 283 tempitem.misc6 = 0;
8136 283 tempitem.misc7 = 0;
8137 283 tempitem.misc8 = 0;
8138 283 tempitem.misc9 = 0;
8139 283 tempitem.misc10 = 0;
8140 283 tempitem.wpn = 0;
8141 283 tempitem.wpn2 = 0;
8142 283 tempitem.wpn3 = 0;
8143 283 tempitem.wpn4 = 0;
8144 283 tempitem.wpn5 = 0;
8145 283 tempitem.wpn6 = 0;
8146 283 tempitem.wpn7 = 0;
8147 283 tempitem.wpn8 = 0;
8148 283 tempitem.wpn9 = 0;
8149 283 tempitem.wpn10 = 0;
8150 283 break;
8151 }
8152 case itype_bow:
8153 {
8154 184 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8155 184 tempitem.misc1 = 0;
8156 184 tempitem.misc2 = 0;
8157 184 tempitem.misc3 = 0;
8158 184 tempitem.misc4 = 0;
8159 184 tempitem.misc5 = 0;
8160 184 tempitem.misc6 = 0;
8161 184 tempitem.misc7 = 0;
8162 184 tempitem.misc8 = 0;
8163 184 tempitem.misc9 = 0;
8164 184 tempitem.misc10 = 0;
8165 184 tempitem.wpn = 0;
8166 184 tempitem.wpn2 = 0;
8167 184 tempitem.wpn3 = 0;
8168 184 tempitem.wpn4 = 0;
8169 184 tempitem.wpn5 = 0;
8170 184 tempitem.wpn6 = 0;
8171 184 tempitem.wpn7 = 0;
8172 184 tempitem.wpn8 = 0;
8173 184 tempitem.wpn9 = 0;
8174 184 tempitem.wpn10 = 0;
8175 184 break;
8176 }
8177 case itype_raft:
8178 {
8179 92 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8180 92 tempitem.misc1 = 0;
8181 92 tempitem.misc2 = 0;
8182 92 tempitem.misc3 = 0;
8183 92 tempitem.misc4 = 0;
8184 92 tempitem.misc5 = 0;
8185 92 tempitem.misc6 = 0;
8186 92 tempitem.misc7 = 0;
8187 92 tempitem.misc8 = 0;
8188 92 tempitem.misc9 = 0;
8189 92 tempitem.misc10 = 0;
8190 92 tempitem.wpn = 0;
8191 92 tempitem.wpn2 = 0;
8192 92 tempitem.wpn3 = 0;
8193 92 tempitem.wpn4 = 0;
8194 92 tempitem.wpn5 = 0;
8195 92 tempitem.wpn6 = 0;
8196 92 tempitem.wpn7 = 0;
8197 92 tempitem.wpn8 = 0;
8198 92 tempitem.wpn9 = 0;
8199 92 tempitem.wpn10 = 0;
8200 92 break;
8201 }
8202 case itype_ladder:
8203 {
8204 184 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8205 184 tempitem.misc1 = 0;
8206 184 tempitem.misc2 = 0;
8207 184 tempitem.misc3 = 0;
8208 184 tempitem.misc4 = 0;
8209 184 tempitem.misc5 = 0;
8210 184 tempitem.misc6 = 0;
8211 184 tempitem.misc7 = 0;
8212 184 tempitem.misc8 = 0;
8213 184 tempitem.misc9 = 0;
8214 184 tempitem.misc10 = 0;
8215 184 tempitem.wpn = 0;
8216 184 tempitem.wpn2 = 0;
8217 184 tempitem.wpn3 = 0;
8218 184 tempitem.wpn4 = 0;
8219 184 tempitem.wpn5 = 0;
8220 184 tempitem.wpn6 = 0;
8221 184 tempitem.wpn7 = 0;
8222 184 tempitem.wpn8 = 0;
8223 184 tempitem.wpn9 = 0;
8224 184 tempitem.wpn10 = 0;
8225 184 break;
8226 }
8227 case itype_book:
8228 {
8229 107 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8230 107 tempitem.misc1 = 0;
8231 107 tempitem.misc2 = 0;
8232 107 tempitem.misc3 = 0;
8233 107 tempitem.misc4 = 0;
8234 107 tempitem.misc5 = 0;
8235 107 tempitem.misc6 = 0;
8236 107 tempitem.misc7 = 0;
8237 107 tempitem.misc8 = 0;
8238 107 tempitem.misc9 = 0;
8239 107 tempitem.misc10 = 0;
8240 107 tempitem.wpn3 = 0;
8241 107 tempitem.wpn4 = 0;
8242 107 tempitem.wpn5 = 0;
8243 107 tempitem.wpn6 = 0;
8244 107 tempitem.wpn7 = 0;
8245 107 tempitem.wpn8 = 0;
8246 107 tempitem.wpn9 = 0;
8247 107 tempitem.wpn10 = 0;
8248 107 break;
8249 }
8250 case itype_magickey:
8251 {
8252 92 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8253 92 tempitem.misc1 = 0;
8254 92 tempitem.misc2 = 0;
8255 92 tempitem.misc3 = 0;
8256 92 tempitem.misc4 = 0;
8257 92 tempitem.misc5 = 0;
8258 92 tempitem.misc6 = 0;
8259 92 tempitem.misc7 = 0;
8260 92 tempitem.misc8 = 0;
8261 92 tempitem.misc9 = 0;
8262 92 tempitem.misc10 = 0;
8263 92 tempitem.wpn = 0;
8264 92 tempitem.wpn2 = 0;
8265 92 tempitem.wpn3 = 0;
8266 92 tempitem.wpn4 = 0;
8267 92 tempitem.wpn5 = 0;
8268 92 tempitem.wpn6 = 0;
8269 92 tempitem.wpn7 = 0;
8270 92 tempitem.wpn8 = 0;
8271 92 tempitem.wpn9 = 0;
8272 92 tempitem.wpn10 = 0;
8273 92 break;
8274 }
8275 case itype_bracelet:
8276 {
8277 279 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8278 279 tempitem.misc1 = 0;
8279 279 tempitem.misc2 = 0;
8280 279 tempitem.misc3 = 0;
8281 279 tempitem.misc4 = 0;
8282 279 tempitem.misc5 = 0;
8283 279 tempitem.misc6 = 0;
8284 279 tempitem.misc7 = 0;
8285 279 tempitem.misc8 = 0;
8286 279 tempitem.misc9 = 0;
8287 279 tempitem.misc10 = 0;
8288 279 tempitem.wpn = 0;
8289 279 tempitem.wpn2 = 0;
8290 279 tempitem.wpn3 = 0;
8291 279 tempitem.wpn4 = 0;
8292 279 tempitem.wpn5 = 0;
8293 279 tempitem.wpn6 = 0;
8294 279 tempitem.wpn7 = 0;
8295 279 tempitem.wpn8 = 0;
8296 279 tempitem.wpn9 = 0;
8297 279 tempitem.wpn10 = 0;
8298 279 break;
8299 }
8300 case itype_flippers:
8301 {
8302 93 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8303 93 tempitem.misc1 = 0;
8304 93 tempitem.misc2 = 0;
8305 93 tempitem.misc3 = 0;
8306 93 tempitem.misc4 = 0;
8307 93 tempitem.misc5 = 0;
8308 93 tempitem.misc6 = 0;
8309 93 tempitem.misc7 = 0;
8310 93 tempitem.misc8 = 0;
8311 93 tempitem.misc9 = 0;
8312 93 tempitem.misc10 = 0;
8313 93 tempitem.wpn = 0;
8314 93 tempitem.wpn2 = 0;
8315 93 tempitem.wpn3 = 0;
8316 93 tempitem.wpn4 = 0;
8317 93 tempitem.wpn5 = 0;
8318 93 tempitem.wpn6 = 0;
8319 93 tempitem.wpn7 = 0;
8320 93 tempitem.wpn8 = 0;
8321 93 tempitem.wpn9 = 0;
8322 93 tempitem.wpn10 = 0;
8323 93 break;
8324 }
8325 case itype_boots:
8326 {
8327 94 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8328 94 tempitem.misc1 = 0;
8329 94 tempitem.misc2 = 0;
8330 94 tempitem.misc3 = 0;
8331 94 tempitem.misc4 = 0;
8332 94 tempitem.misc5 = 0;
8333 94 tempitem.misc6 = 0;
8334 94 tempitem.misc7 = 0;
8335 94 tempitem.misc8 = 0;
8336 94 tempitem.misc9 = 0;
8337 94 tempitem.misc10 = 0;
8338 94 tempitem.wpn = 0;
8339 94 tempitem.wpn2 = 0;
8340 94 tempitem.wpn3 = 0;
8341 94 tempitem.wpn4 = 0;
8342 94 tempitem.wpn5 = 0;
8343 94 tempitem.wpn6 = 0;
8344 94 tempitem.wpn7 = 0;
8345 94 tempitem.wpn8 = 0;
8346 94 tempitem.wpn9 = 0;
8347 94 tempitem.wpn10 = 0;
8348 94 break;
8349 }
8350 case itype_hookshot:
8351 {
8352 184 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8353 184 tempitem.misc5 = 0;
8354 184 tempitem.misc6 = 0;
8355 184 tempitem.misc7 = 0;
8356 184 tempitem.misc8 = 0;
8357 184 tempitem.misc9 = 0;
8358 184 tempitem.misc10 = 0;
8359 184 tempitem.wpn5 = 0;
8360 184 tempitem.wpn6 = 0;
8361 184 tempitem.wpn7 = 0;
8362 184 tempitem.wpn8 = 0;
8363 184 tempitem.wpn9 = 0;
8364 184 tempitem.wpn10 = 0;
8365 184 break;
8366 }
8367 case itype_lens:
8368 {
8369 92 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8370 92 tempitem.misc2 = 0;
8371 92 tempitem.misc3 = 0;
8372 92 tempitem.misc4 = 0;
8373 92 tempitem.misc5 = 0;
8374 92 tempitem.misc6 = 0;
8375 92 tempitem.misc7 = 0;
8376 92 tempitem.misc8 = 0;
8377 92 tempitem.misc9 = 0;
8378 92 tempitem.misc10 = 0;
8379 92 tempitem.wpn = 0;
8380 92 tempitem.wpn2 = 0;
8381 92 tempitem.wpn3 = 0;
8382 92 tempitem.wpn4 = 0;
8383 92 tempitem.wpn5 = 0;
8384 92 tempitem.wpn6 = 0;
8385 92 tempitem.wpn7 = 0;
8386 92 tempitem.wpn8 = 0;
8387 92 tempitem.wpn9 = 0;
8388 92 tempitem.wpn10 = 0;
8389 92 break;
8390 }
8391 case itype_hammer:
8392 {
8393 93 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8394 93 tempitem.misc1 = 0;
8395 93 tempitem.misc2 = 0;
8396 93 tempitem.misc3 = 0;
8397 93 tempitem.misc4 = 0;
8398 93 tempitem.misc5 = 0;
8399 93 tempitem.misc6 = 0;
8400 93 tempitem.misc7 = 0;
8401 93 tempitem.misc8 = 0;
8402 93 tempitem.misc9 = 0;
8403 93 tempitem.misc10 = 0;
8404 93 tempitem.wpn3 = 0;
8405 93 tempitem.wpn4 = 0;
8406 93 tempitem.wpn5 = 0;
8407 93 tempitem.wpn6 = 0;
8408 93 tempitem.wpn7 = 0;
8409 93 tempitem.wpn8 = 0;
8410 93 tempitem.wpn9 = 0;
8411 93 tempitem.wpn10 = 0;
8412 93 break;
8413 }
8414 case itype_divinefire:
8415 {
8416 92 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG4 | ITEM_FLAG5);
8417 92 tempitem.misc3 = 0;
8418 92 tempitem.misc4 = 0;
8419 92 tempitem.misc5 = 0;
8420 92 tempitem.misc6 = 0;
8421 92 tempitem.misc7 = 0;
8422 92 tempitem.misc8 = 0;
8423 92 tempitem.misc9 = 0;
8424 92 tempitem.misc10 = 0;
8425 92 tempitem.wpn6 = 0;
8426 92 tempitem.wpn7 = 0;
8427 92 tempitem.wpn8 = 0;
8428 92 tempitem.wpn9 = 0;
8429 92 tempitem.wpn10 = 0;
8430 92 break;
8431 }
8432 case itype_divineescape:
8433 {
8434 92 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8435 92 tempitem.misc2 = 0;
8436 92 tempitem.misc3 = 0;
8437 92 tempitem.misc4 = 0;
8438 92 tempitem.misc5 = 0;
8439 92 tempitem.misc6 = 0;
8440 92 tempitem.misc7 = 0;
8441 92 tempitem.misc8 = 0;
8442 92 tempitem.misc9 = 0;
8443 92 tempitem.misc10 = 0;
8444 92 tempitem.wpn = 0;
8445 92 tempitem.wpn2 = 0;
8446 92 tempitem.wpn3 = 0;
8447 92 tempitem.wpn4 = 0;
8448 92 tempitem.wpn5 = 0;
8449 92 tempitem.wpn6 = 0;
8450 92 tempitem.wpn7 = 0;
8451 92 tempitem.wpn8 = 0;
8452 92 tempitem.wpn9 = 0;
8453 92 tempitem.wpn10 = 0;
8454 92 break;
8455 }
8456 case itype_divineprotection:
8457 {
8458 92 tempitem.flags &= ~ (ITEM_FLAG5);
8459 92 tempitem.misc2 = 0;
8460 92 tempitem.misc3 = 0;
8461 92 tempitem.misc4 = 0;
8462 92 tempitem.misc5 = 0;
8463 92 tempitem.misc6 = 0;
8464 92 tempitem.misc7 = 0;
8465 92 tempitem.misc8 = 0;
8466 92 tempitem.misc9 = 0;
8467 92 tempitem.misc10 = 0;
8468 92 break;
8469 }
8470 case itype_bomb:
8471 {
8472 107 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8473 107 tempitem.misc4 = 0;
8474 107 tempitem.misc5 = 0;
8475 107 tempitem.misc6 = 0;
8476 107 tempitem.misc7 = 0;
8477 107 tempitem.misc8 = 0;
8478 107 tempitem.misc9 = 0;
8479 107 tempitem.misc10 = 0;
8480 107 tempitem.wpn3 = 0;
8481 107 tempitem.wpn4 = 0;
8482 107 tempitem.wpn5 = 0;
8483 107 tempitem.wpn6 = 0;
8484 107 tempitem.wpn7 = 0;
8485 107 tempitem.wpn8 = 0;
8486 107 tempitem.wpn9 = 0;
8487 107 tempitem.wpn10 = 0;
8488 107 break;
8489 }
8490 case itype_sbomb:
8491 {
8492 92 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8493 92 tempitem.misc4 = 0;
8494 92 tempitem.misc5 = 0;
8495 92 tempitem.misc6 = 0;
8496 92 tempitem.misc7 = 0;
8497 92 tempitem.misc8 = 0;
8498 92 tempitem.misc9 = 0;
8499 92 tempitem.misc10 = 0;
8500 92 tempitem.wpn3 = 0;
8501 92 tempitem.wpn4 = 0;
8502 92 tempitem.wpn5 = 0;
8503 92 tempitem.wpn6 = 0;
8504 92 tempitem.wpn7 = 0;
8505 92 tempitem.wpn8 = 0;
8506 92 tempitem.wpn9 = 0;
8507 92 tempitem.wpn10 = 0;
8508 92 break;
8509 }
8510 case itype_clock:
8511 {
8512 93 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8513 93 tempitem.misc2 = 0;
8514 93 tempitem.misc3 = 0;
8515 93 tempitem.misc4 = 0;
8516 93 tempitem.misc5 = 0;
8517 93 tempitem.misc6 = 0;
8518 93 tempitem.misc7 = 0;
8519 93 tempitem.misc8 = 0;
8520 93 tempitem.misc9 = 0;
8521 93 tempitem.misc10 = 0;
8522 93 tempitem.wpn = 0;
8523 93 tempitem.wpn2 = 0;
8524 93 tempitem.wpn3 = 0;
8525 93 tempitem.wpn4 = 0;
8526 93 tempitem.wpn5 = 0;
8527 93 tempitem.wpn6 = 0;
8528 93 tempitem.wpn7 = 0;
8529 93 tempitem.wpn8 = 0;
8530 93 tempitem.wpn9 = 0;
8531 93 tempitem.wpn10 = 0;
8532 93 break;
8533 }
8534 case itype_key:
8535 {
8536 92 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8537 92 tempitem.misc1 = 0;
8538 92 tempitem.misc2 = 0;
8539 92 tempitem.misc3 = 0;
8540 92 tempitem.misc4 = 0;
8541 92 tempitem.misc5 = 0;
8542 92 tempitem.misc6 = 0;
8543 92 tempitem.misc7 = 0;
8544 92 tempitem.misc8 = 0;
8545 92 tempitem.misc9 = 0;
8546 92 tempitem.misc10 = 0;
8547 92 tempitem.wpn = 0;
8548 92 tempitem.wpn2 = 0;
8549 92 tempitem.wpn3 = 0;
8550 92 tempitem.wpn4 = 0;
8551 92 tempitem.wpn5 = 0;
8552 92 tempitem.wpn6 = 0;
8553 92 tempitem.wpn7 = 0;
8554 92 tempitem.wpn8 = 0;
8555 92 tempitem.wpn9 = 0;
8556 92 tempitem.wpn10 = 0;
8557 92 break;
8558 }
8559 case itype_magiccontainer:
8560 {
8561 93 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8562 93 tempitem.misc1 = 0;
8563 93 tempitem.misc2 = 0;
8564 93 tempitem.misc3 = 0;
8565 93 tempitem.misc4 = 0;
8566 93 tempitem.misc5 = 0;
8567 93 tempitem.misc6 = 0;
8568 93 tempitem.misc7 = 0;
8569 93 tempitem.misc8 = 0;
8570 93 tempitem.misc9 = 0;
8571 93 tempitem.misc10 = 0;
8572 93 tempitem.wpn = 0;
8573 93 tempitem.wpn2 = 0;
8574 93 tempitem.wpn3 = 0;
8575 93 tempitem.wpn4 = 0;
8576 93 tempitem.wpn5 = 0;
8577 93 tempitem.wpn6 = 0;
8578 93 tempitem.wpn7 = 0;
8579 93 tempitem.wpn8 = 0;
8580 93 tempitem.wpn9 = 0;
8581 93 tempitem.wpn10 = 0;
8582 93 break;
8583 }
8584 case itype_triforcepiece:
8585 {
8586 184 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8587 184 tempitem.misc3 = 0;
8588 184 tempitem.misc4 = 0;
8589 184 tempitem.misc5 = 0;
8590 184 tempitem.misc6 = 0;
8591 184 tempitem.misc7 = 0;
8592 184 tempitem.misc8 = 0;
8593 184 tempitem.misc9 = 0;
8594 184 tempitem.misc10 = 0;
8595 184 tempitem.wpn = 0;
8596 184 tempitem.wpn2 = 0;
8597 184 tempitem.wpn3 = 0;
8598 184 tempitem.wpn4 = 0;
8599 184 tempitem.wpn5 = 0;
8600 184 tempitem.wpn6 = 0;
8601 184 tempitem.wpn7 = 0;
8602 184 tempitem.wpn8 = 0;
8603 184 tempitem.wpn9 = 0;
8604 184 tempitem.wpn10 = 0;
8605 184 break;
8606 }
8607 case itype_map: case itype_compass: case itype_bosskey:
8608 {
8609 277 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8610 277 tempitem.misc1 = 0;
8611 277 tempitem.misc2 = 0;
8612 277 tempitem.misc3 = 0;
8613 277 tempitem.misc4 = 0;
8614 277 tempitem.misc5 = 0;
8615 277 tempitem.misc6 = 0;
8616 277 tempitem.misc7 = 0;
8617 277 tempitem.misc8 = 0;
8618 277 tempitem.misc9 = 0;
8619 277 tempitem.misc10 = 0;
8620 277 tempitem.wpn = 0;
8621 277 tempitem.wpn2 = 0;
8622 277 tempitem.wpn3 = 0;
8623 277 tempitem.wpn4 = 0;
8624 277 tempitem.wpn5 = 0;
8625 277 tempitem.wpn6 = 0;
8626 277 tempitem.wpn7 = 0;
8627 277 tempitem.wpn8 = 0;
8628 277 tempitem.wpn9 = 0;
8629 277 tempitem.wpn10 = 0;
8630 277 break;
8631 }
8632 case itype_quiver:
8633 {
8634 368 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8635 368 tempitem.misc3 = 0;
8636 368 tempitem.misc4 = 0;
8637 368 tempitem.misc5 = 0;
8638 368 tempitem.misc6 = 0;
8639 368 tempitem.misc7 = 0;
8640 368 tempitem.misc8 = 0;
8641 368 tempitem.misc9 = 0;
8642 368 tempitem.misc10 = 0;
8643 368 tempitem.wpn = 0;
8644 368 tempitem.wpn2 = 0;
8645 368 tempitem.wpn3 = 0;
8646 368 tempitem.wpn4 = 0;
8647 368 tempitem.wpn5 = 0;
8648 368 tempitem.wpn6 = 0;
8649 368 tempitem.wpn7 = 0;
8650 368 tempitem.wpn8 = 0;
8651 368 tempitem.wpn9 = 0;
8652 368 tempitem.wpn10 = 0;
8653 368 break;
8654 }
8655 case itype_lkey:
8656 {
8657 94 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8658 94 tempitem.misc1 = 0;
8659 94 tempitem.misc2 = 0;
8660 94 tempitem.misc3 = 0;
8661 94 tempitem.misc4 = 0;
8662 94 tempitem.misc5 = 0;
8663 94 tempitem.misc6 = 0;
8664 94 tempitem.misc7 = 0;
8665 94 tempitem.misc8 = 0;
8666 94 tempitem.misc9 = 0;
8667 94 tempitem.misc10 = 0;
8668 94 tempitem.wpn = 0;
8669 94 tempitem.wpn2 = 0;
8670 94 tempitem.wpn3 = 0;
8671 94 tempitem.wpn4 = 0;
8672 94 tempitem.wpn5 = 0;
8673 94 tempitem.wpn6 = 0;
8674 94 tempitem.wpn7 = 0;
8675 94 tempitem.wpn8 = 0;
8676 94 tempitem.wpn9 = 0;
8677 94 tempitem.wpn10 = 0;
8678 94 break;
8679 }
8680 case itype_cbyrna:
8681 {
8682 92 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG5);
8683 92 tempitem.misc4 = 0;
8684 92 tempitem.misc5 = 0;
8685 92 tempitem.misc6 = 0;
8686 92 tempitem.misc7 = 0;
8687 92 tempitem.misc8 = 0;
8688 92 tempitem.misc9 = 0;
8689 92 tempitem.misc10 = 0;
8690 92 tempitem.wpn6 = 0;
8691 92 tempitem.wpn7 = 0;
8692 92 tempitem.wpn8 = 0;
8693 92 tempitem.wpn9 = 0;
8694 92 tempitem.wpn10 = 0;
8695 92 break;
8696 }
8697 case itype_rupee: case itype_arrowammo:
8698 {
8699 1135 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8700 1135 tempitem.misc1 = 0;
8701 1135 tempitem.misc2 = 0;
8702 1135 tempitem.misc3 = 0;
8703 1135 tempitem.misc4 = 0;
8704 1135 tempitem.misc5 = 0;
8705 1135 tempitem.misc6 = 0;
8706 1135 tempitem.misc7 = 0;
8707 1135 tempitem.misc8 = 0;
8708 1135 tempitem.misc9 = 0;
8709 1135 tempitem.misc10 = 0;
8710 1135 tempitem.wpn = 0;
8711 1135 tempitem.wpn2 = 0;
8712 1135 tempitem.wpn3 = 0;
8713 1135 tempitem.wpn4 = 0;
8714 1135 tempitem.wpn5 = 0;
8715 1135 tempitem.wpn6 = 0;
8716 1135 tempitem.wpn7 = 0;
8717 1135 tempitem.wpn8 = 0;
8718 1135 tempitem.wpn9 = 0;
8719 1135 tempitem.wpn10 = 0;
8720 1135 break;
8721 }
8722 case itype_fairy:
8723 {
8724 168 tempitem.flags &= ~ (ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8725 168 tempitem.misc4 = 0;
8726 168 tempitem.misc5 = 0;
8727 168 tempitem.misc6 = 0;
8728 168 tempitem.misc7 = 0;
8729 168 tempitem.misc8 = 0;
8730 168 tempitem.misc9 = 0;
8731 168 tempitem.misc10 = 0;
8732 168 tempitem.wpn = 0;
8733 168 tempitem.wpn2 = 0;
8734 168 tempitem.wpn3 = 0;
8735 168 tempitem.wpn4 = 0;
8736 168 tempitem.wpn5 = 0;
8737 168 tempitem.wpn6 = 0;
8738 168 tempitem.wpn7 = 0;
8739 168 tempitem.wpn8 = 0;
8740 168 tempitem.wpn9 = 0;
8741 168 tempitem.wpn10 = 0;
8742 168 break;
8743 }
8744 case itype_magic: case itype_heart: case itype_heartcontainer: case itype_heartpiece: case itype_killem: case itype_bombammo:
8745 {
8746 983 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8747 983 tempitem.misc1 = 0;
8748 983 tempitem.misc2 = 0;
8749 983 tempitem.misc3 = 0;
8750 983 tempitem.misc4 = 0;
8751 983 tempitem.misc5 = 0;
8752 983 tempitem.misc6 = 0;
8753 983 tempitem.misc7 = 0;
8754 983 tempitem.misc8 = 0;
8755 983 tempitem.misc9 = 0;
8756 983 tempitem.misc10 = 0;
8757 983 tempitem.wpn = 0;
8758 983 tempitem.wpn2 = 0;
8759 983 tempitem.wpn3 = 0;
8760 983 tempitem.wpn4 = 0;
8761 983 tempitem.wpn5 = 0;
8762 983 tempitem.wpn6 = 0;
8763 983 tempitem.wpn7 = 0;
8764 983 tempitem.wpn8 = 0;
8765 983 tempitem.wpn9 = 0;
8766 983 tempitem.wpn10 = 0;
8767 983 break;
8768 }
8769 case itype_bombbag:
8770 {
8771 368 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8772 368 tempitem.misc3 = 0;
8773 368 tempitem.misc4 = 0;
8774 368 tempitem.misc5 = 0;
8775 368 tempitem.misc6 = 0;
8776 368 tempitem.misc7 = 0;
8777 368 tempitem.misc8 = 0;
8778 368 tempitem.misc9 = 0;
8779 368 tempitem.misc10 = 0;
8780 368 tempitem.wpn = 0;
8781 368 tempitem.wpn2 = 0;
8782 368 tempitem.wpn3 = 0;
8783 368 tempitem.wpn4 = 0;
8784 368 tempitem.wpn5 = 0;
8785 368 tempitem.wpn6 = 0;
8786 368 tempitem.wpn7 = 0;
8787 368 tempitem.wpn8 = 0;
8788 368 tempitem.wpn9 = 0;
8789 368 tempitem.wpn10 = 0;
8790 368 break;
8791 }
8792 case itype_rocs:
8793 {
8794 92 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8795 92 tempitem.misc1 = 0;
8796 92 tempitem.misc2 = 0;
8797 92 tempitem.misc3 = 0;
8798 92 tempitem.misc4 = 0;
8799 92 tempitem.misc5 = 0;
8800 92 tempitem.misc6 = 0;
8801 92 tempitem.misc7 = 0;
8802 92 tempitem.misc8 = 0;
8803 92 tempitem.misc9 = 0;
8804 92 tempitem.misc10 = 0;
8805 92 tempitem.wpn = 0;
8806 92 tempitem.wpn2 = 0;
8807 92 tempitem.wpn3 = 0;
8808 92 tempitem.wpn4 = 0;
8809 92 tempitem.wpn5 = 0;
8810 92 tempitem.wpn6 = 0;
8811 92 tempitem.wpn7 = 0;
8812 92 tempitem.wpn8 = 0;
8813 92 tempitem.wpn9 = 0;
8814 92 tempitem.wpn10 = 0;
8815 92 break;
8816 }
8817 case itype_hoverboots:
8818 {
8819 92 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8820 92 tempitem.misc2 = 0;
8821 92 tempitem.misc3 = 0;
8822 92 tempitem.misc4 = 0;
8823 92 tempitem.misc5 = 0;
8824 92 tempitem.misc6 = 0;
8825 92 tempitem.misc7 = 0;
8826 92 tempitem.misc8 = 0;
8827 92 tempitem.misc9 = 0;
8828 92 tempitem.misc10 = 0;
8829 92 tempitem.wpn2 = 0;
8830 92 tempitem.wpn3 = 0;
8831 92 tempitem.wpn4 = 0;
8832 92 tempitem.wpn5 = 0;
8833 92 tempitem.wpn6 = 0;
8834 92 tempitem.wpn7 = 0;
8835 92 tempitem.wpn8 = 0;
8836 92 tempitem.wpn9 = 0;
8837 92 tempitem.wpn10 = 0;
8838 92 break;
8839 }
8840 case itype_spinscroll:
8841 {
8842 92 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8843 92 tempitem.misc2 = 0;
8844 92 tempitem.misc3 = 0;
8845 92 tempitem.misc4 = 0;
8846 92 tempitem.misc5 = 0;
8847 92 tempitem.misc6 = 0;
8848 92 tempitem.misc7 = 0;
8849 92 tempitem.misc8 = 0;
8850 92 tempitem.misc9 = 0;
8851 92 tempitem.misc10 = 0;
8852 92 tempitem.wpn = 0;
8853 92 tempitem.wpn2 = 0;
8854 92 tempitem.wpn3 = 0;
8855 92 tempitem.wpn4 = 0;
8856 92 tempitem.wpn5 = 0;
8857 92 tempitem.wpn6 = 0;
8858 92 tempitem.wpn7 = 0;
8859 92 tempitem.wpn8 = 0;
8860 92 tempitem.wpn9 = 0;
8861 92 tempitem.wpn10 = 0;
8862 92 break;
8863 }
8864 case itype_crossscroll:
8865 {
8866 92 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8867 92 tempitem.misc1 = 0;
8868 92 tempitem.misc2 = 0;
8869 92 tempitem.misc3 = 0;
8870 92 tempitem.misc4 = 0;
8871 92 tempitem.misc5 = 0;
8872 92 tempitem.misc6 = 0;
8873 92 tempitem.misc7 = 0;
8874 92 tempitem.misc8 = 0;
8875 92 tempitem.misc9 = 0;
8876 92 tempitem.misc10 = 0;
8877 92 tempitem.wpn = 0;
8878 92 tempitem.wpn2 = 0;
8879 92 tempitem.wpn3 = 0;
8880 92 tempitem.wpn4 = 0;
8881 92 tempitem.wpn5 = 0;
8882 92 tempitem.wpn6 = 0;
8883 92 tempitem.wpn7 = 0;
8884 92 tempitem.wpn8 = 0;
8885 92 tempitem.wpn9 = 0;
8886 92 tempitem.wpn10 = 0;
8887 92 break;
8888 }
8889 case itype_quakescroll:
8890 {
8891 92 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8892 92 tempitem.misc3 = 0;
8893 92 tempitem.misc4 = 0;
8894 92 tempitem.misc5 = 0;
8895 92 tempitem.misc6 = 0;
8896 92 tempitem.misc7 = 0;
8897 92 tempitem.misc8 = 0;
8898 92 tempitem.misc9 = 0;
8899 92 tempitem.misc10 = 0;
8900 92 tempitem.wpn = 0;
8901 92 tempitem.wpn2 = 0;
8902 92 tempitem.wpn3 = 0;
8903 92 tempitem.wpn4 = 0;
8904 92 tempitem.wpn5 = 0;
8905 92 tempitem.wpn6 = 0;
8906 92 tempitem.wpn7 = 0;
8907 92 tempitem.wpn8 = 0;
8908 92 tempitem.wpn9 = 0;
8909 92 tempitem.wpn10 = 0;
8910 92 break;
8911 }
8912 case itype_whispring:
8913 {
8914 185 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8915 185 tempitem.misc2 = 0;
8916 185 tempitem.misc3 = 0;
8917 185 tempitem.misc4 = 0;
8918 185 tempitem.misc5 = 0;
8919 185 tempitem.misc6 = 0;
8920 185 tempitem.misc7 = 0;
8921 185 tempitem.misc8 = 0;
8922 185 tempitem.misc9 = 0;
8923 185 tempitem.misc10 = 0;
8924 185 tempitem.wpn = 0;
8925 185 tempitem.wpn2 = 0;
8926 185 tempitem.wpn3 = 0;
8927 185 tempitem.wpn4 = 0;
8928 185 tempitem.wpn5 = 0;
8929 185 tempitem.wpn6 = 0;
8930 185 tempitem.wpn7 = 0;
8931 185 tempitem.wpn8 = 0;
8932 185 tempitem.wpn9 = 0;
8933 185 tempitem.wpn10 = 0;
8934 185 break;
8935 }
8936 case itype_chargering:
8937 {
8938 184 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8939 184 tempitem.misc3 = 0;
8940 184 tempitem.misc4 = 0;
8941 184 tempitem.misc5 = 0;
8942 184 tempitem.misc6 = 0;
8943 184 tempitem.misc7 = 0;
8944 184 tempitem.misc8 = 0;
8945 184 tempitem.misc9 = 0;
8946 184 tempitem.misc10 = 0;
8947 184 tempitem.wpn = 0;
8948 184 tempitem.wpn2 = 0;
8949 184 tempitem.wpn3 = 0;
8950 184 tempitem.wpn4 = 0;
8951 184 tempitem.wpn5 = 0;
8952 184 tempitem.wpn6 = 0;
8953 184 tempitem.wpn7 = 0;
8954 184 tempitem.wpn8 = 0;
8955 184 tempitem.wpn9 = 0;
8956 184 tempitem.wpn10 = 0;
8957 184 break;
8958 }
8959 case itype_perilscroll:
8960 {
8961 92 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8962 92 tempitem.misc2 = 0;
8963 92 tempitem.misc3 = 0;
8964 92 tempitem.misc4 = 0;
8965 92 tempitem.misc5 = 0;
8966 92 tempitem.misc6 = 0;
8967 92 tempitem.misc7 = 0;
8968 92 tempitem.misc8 = 0;
8969 92 tempitem.misc9 = 0;
8970 92 tempitem.misc10 = 0;
8971 92 tempitem.wpn = 0;
8972 92 tempitem.wpn2 = 0;
8973 92 tempitem.wpn3 = 0;
8974 92 tempitem.wpn4 = 0;
8975 92 tempitem.wpn5 = 0;
8976 92 tempitem.wpn6 = 0;
8977 92 tempitem.wpn7 = 0;
8978 92 tempitem.wpn8 = 0;
8979 92 tempitem.wpn9 = 0;
8980 92 tempitem.wpn10 = 0;
8981 92 break;
8982 }
8983 case itype_wealthmedal:
8984 {
8985 277 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8986 277 tempitem.misc2 = 0;
8987 277 tempitem.misc3 = 0;
8988 277 tempitem.misc4 = 0;
8989 277 tempitem.misc5 = 0;
8990 277 tempitem.misc6 = 0;
8991 277 tempitem.misc7 = 0;
8992 277 tempitem.misc8 = 0;
8993 277 tempitem.misc9 = 0;
8994 277 tempitem.misc10 = 0;
8995 277 tempitem.wpn = 0;
8996 277 tempitem.wpn2 = 0;
8997 277 tempitem.wpn3 = 0;
8998 277 tempitem.wpn4 = 0;
8999 277 tempitem.wpn5 = 0;
9000 277 tempitem.wpn6 = 0;
9001 277 tempitem.wpn7 = 0;
9002 277 tempitem.wpn8 = 0;
9003 277 tempitem.wpn9 = 0;
9004 277 tempitem.wpn10 = 0;
9005 277 break;
9006 }
9007 case itype_heartring:
9008 {
9009 278 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
9010 278 tempitem.misc3 = 0;
9011 278 tempitem.misc4 = 0;
9012 278 tempitem.misc5 = 0;
9013 278 tempitem.misc6 = 0;
9014 278 tempitem.misc7 = 0;
9015 278 tempitem.misc8 = 0;
9016 278 tempitem.misc9 = 0;
9017 278 tempitem.misc10 = 0;
9018 278 tempitem.wpn = 0;
9019 278 tempitem.wpn2 = 0;
9020 278 tempitem.wpn3 = 0;
9021 278 tempitem.wpn4 = 0;
9022 278 tempitem.wpn5 = 0;
9023 278 tempitem.wpn6 = 0;
9024 278 tempitem.wpn7 = 0;
9025 278 tempitem.wpn8 = 0;
9026 278 tempitem.wpn9 = 0;
9027 278 tempitem.wpn10 = 0;
9028 278 break;
9029 }
9030 case itype_magicring:
9031 {
9032 372 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
9033 372 tempitem.misc3 = 0;
9034 372 tempitem.misc4 = 0;
9035 372 tempitem.misc5 = 0;
9036 372 tempitem.misc6 = 0;
9037 372 tempitem.misc7 = 0;
9038 372 tempitem.misc8 = 0;
9039 372 tempitem.misc9 = 0;
9040 372 tempitem.misc10 = 0;
9041 372 tempitem.wpn = 0;
9042 372 tempitem.wpn2 = 0;
9043 372 tempitem.wpn3 = 0;
9044 372 tempitem.wpn4 = 0;
9045 372 tempitem.wpn5 = 0;
9046 372 tempitem.wpn6 = 0;
9047 372 tempitem.wpn7 = 0;
9048 372 tempitem.wpn8 = 0;
9049 372 tempitem.wpn9 = 0;
9050 372 tempitem.wpn10 = 0;
9051 372 break;
9052 }
9053 case itype_spinscroll2:
9054 {
9055 92 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
9056 92 tempitem.misc2 = 0;
9057 92 tempitem.misc3 = 0;
9058 92 tempitem.misc4 = 0;
9059 92 tempitem.misc5 = 0;
9060 92 tempitem.misc6 = 0;
9061 92 tempitem.misc7 = 0;
9062 92 tempitem.misc8 = 0;
9063 92 tempitem.misc9 = 0;
9064 92 tempitem.misc10 = 0;
9065 92 tempitem.wpn = 0;
9066 92 tempitem.wpn2 = 0;
9067 92 tempitem.wpn3 = 0;
9068 92 tempitem.wpn4 = 0;
9069 92 tempitem.wpn5 = 0;
9070 92 tempitem.wpn6 = 0;
9071 92 tempitem.wpn7 = 0;
9072 92 tempitem.wpn8 = 0;
9073 92 tempitem.wpn9 = 0;
9074 92 tempitem.wpn10 = 0;
9075 92 break;
9076 }
9077 case itype_quakescroll2:
9078 {
9079 92 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
9080 92 tempitem.misc3 = 0;
9081 92 tempitem.misc4 = 0;
9082 92 tempitem.misc5 = 0;
9083 92 tempitem.misc6 = 0;
9084 92 tempitem.misc7 = 0;
9085 92 tempitem.misc8 = 0;
9086 92 tempitem.misc9 = 0;
9087 92 tempitem.misc10 = 0;
9088 92 tempitem.wpn = 0;
9089 92 tempitem.wpn2 = 0;
9090 92 tempitem.wpn3 = 0;
9091 92 tempitem.wpn4 = 0;
9092 92 tempitem.wpn5 = 0;
9093 92 tempitem.wpn6 = 0;
9094 92 tempitem.wpn7 = 0;
9095 92 tempitem.wpn8 = 0;
9096 92 tempitem.wpn9 = 0;
9097 92 tempitem.wpn10 = 0;
9098 92 break;
9099 }
9100 case itype_agony:
9101 {
9102 92 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
9103 92 tempitem.misc2 = 0;
9104 92 tempitem.misc3 = 0;
9105 92 tempitem.misc4 = 0;
9106 92 tempitem.misc5 = 0;
9107 92 tempitem.misc6 = 0;
9108 92 tempitem.misc7 = 0;
9109 92 tempitem.misc8 = 0;
9110 92 tempitem.misc9 = 0;
9111 92 tempitem.misc10 = 0;
9112 92 tempitem.wpn = 0;
9113 92 tempitem.wpn2 = 0;
9114 92 tempitem.wpn3 = 0;
9115 92 tempitem.wpn4 = 0;
9116 92 tempitem.wpn5 = 0;
9117 92 tempitem.wpn6 = 0;
9118 92 tempitem.wpn7 = 0;
9119 92 tempitem.wpn8 = 0;
9120 92 tempitem.wpn9 = 0;
9121 92 tempitem.wpn10 = 0;
9122 92 break;
9123 }
9124 case itype_stompboots:
9125 {
9126 92 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
9127 92 tempitem.misc1 = 0;
9128 92 tempitem.misc2 = 0;
9129 92 tempitem.misc3 = 0;
9130 92 tempitem.misc4 = 0;
9131 92 tempitem.misc5 = 0;
9132 92 tempitem.misc6 = 0;
9133 92 tempitem.misc7 = 0;
9134 92 tempitem.misc8 = 0;
9135 92 tempitem.misc9 = 0;
9136 92 tempitem.misc10 = 0;
9137 92 tempitem.wpn = 0;
9138 92 tempitem.wpn2 = 0;
9139 92 tempitem.wpn3 = 0;
9140 92 tempitem.wpn4 = 0;
9141 92 tempitem.wpn5 = 0;
9142 92 tempitem.wpn6 = 0;
9143 92 tempitem.wpn7 = 0;
9144 92 tempitem.wpn8 = 0;
9145 92 tempitem.wpn9 = 0;
9146 92 tempitem.wpn10 = 0;
9147 92 break;
9148 }
9149 case itype_whimsicalring:
9150 {
9151 92 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
9152 92 tempitem.misc2 = 0;
9153 92 tempitem.misc3 = 0;
9154 92 tempitem.misc4 = 0;
9155 92 tempitem.misc5 = 0;
9156 92 tempitem.misc6 = 0;
9157 92 tempitem.misc7 = 0;
9158 92 tempitem.misc8 = 0;
9159 92 tempitem.misc9 = 0;
9160 92 tempitem.misc10 = 0;
9161 92 tempitem.wpn = 0;
9162 92 tempitem.wpn2 = 0;
9163 92 tempitem.wpn3 = 0;
9164 92 tempitem.wpn4 = 0;
9165 92 tempitem.wpn5 = 0;
9166 92 tempitem.wpn6 = 0;
9167 92 tempitem.wpn7 = 0;
9168 92 tempitem.wpn8 = 0;
9169 92 tempitem.wpn9 = 0;
9170 92 tempitem.wpn10 = 0;
9171 92 break;
9172 }
9173 case itype_perilring:
9174 {
9175 93 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
9176 93 tempitem.misc2 = 0;
9177 93 tempitem.misc3 = 0;
9178 93 tempitem.misc4 = 0;
9179 93 tempitem.misc5 = 0;
9180 93 tempitem.misc6 = 0;
9181 93 tempitem.misc7 = 0;
9182 93 tempitem.misc8 = 0;
9183 93 tempitem.misc9 = 0;
9184 93 tempitem.misc10 = 0;
9185 93 tempitem.wpn = 0;
9186 93 tempitem.wpn2 = 0;
9187 93 tempitem.wpn3 = 0;
9188 93 tempitem.wpn4 = 0;
9189 93 tempitem.wpn5 = 0;
9190 93 tempitem.wpn6 = 0;
9191 93 tempitem.wpn7 = 0;
9192 93 tempitem.wpn8 = 0;
9193 93 tempitem.wpn9 = 0;
9194 93 tempitem.wpn10 = 0;
9195 93 break;
9196 }
9197 case itype_custom1: case itype_custom2: case itype_custom3: case itype_custom4: case itype_custom5:
9198 case itype_custom6: case itype_custom7: case itype_custom8: case itype_custom9: case itype_custom10:
9199 case itype_custom11: case itype_custom12: case itype_custom13: case itype_custom14: case itype_custom15:
9200 case itype_custom16: case itype_custom17: case itype_custom18: case itype_custom19: case itype_custom20:
9201 case itype_bowandarrow: case itype_letterpotion: case itype_misc:
9202 {
9203 2541 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
9204 2541 tempitem.misc1 = 0;
9205 2541 tempitem.misc2 = 0;
9206 2541 tempitem.misc3 = 0;
9207 2541 tempitem.misc4 = 0;
9208 2541 tempitem.misc5 = 0;
9209 2541 tempitem.misc6 = 0;
9210 2541 tempitem.misc7 = 0;
9211 2541 tempitem.misc8 = 0;
9212 2541 tempitem.misc9 = 0;
9213 2541 tempitem.misc10 = 0;
9214 2541 tempitem.wpn = 0;
9215 2541 tempitem.wpn2 = 0;
9216 2541 tempitem.wpn3 = 0;
9217 2541 tempitem.wpn4 = 0;
9218 2541 tempitem.wpn5 = 0;
9219 2541 tempitem.wpn6 = 0;
9220 2541 tempitem.wpn7 = 0;
9221 2541 tempitem.wpn8 = 0;
9222 2541 tempitem.wpn9 = 0;
9223 2541 tempitem.wpn10 = 0;
9224 2541 break;
9225 }
9226 }
9227 23808 }
9228 //Port quest rules to items
9229
2/2
✓ Branch 0 taken 9728 times.
✓ Branch 1 taken 23808 times.
33536 if( s_version <= 31)
9230 {
9231
2/2
✓ Branch 0 taken 107 times.
✓ Branch 1 taken 23701 times.
23808 if(tempitem.family == itype_bomb)
9232 {
9233
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 90 times.
107 if ( get_qr(qr_OUCHBOMBS) ) tempitem.flags |= ITEM_FLAG2;
9234 90 else tempitem.flags &= ~ ITEM_FLAG2;
9235 107 }
9236
2/2
✓ Branch 0 taken 92 times.
✓ Branch 1 taken 23609 times.
23701 else if(tempitem.family == itype_sbomb)
9237 {
9238
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 75 times.
92 if ( get_qr(qr_OUCHBOMBS) ) tempitem.flags |= ITEM_FLAG2;
9239 75 else tempitem.flags &= ~ ITEM_FLAG2;
9240 92 }
9241
9242
2/2
✓ Branch 0 taken 277 times.
✓ Branch 1 taken 23332 times.
23609 else if(tempitem.family == itype_brang)
9243 {
9244
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 277 times.
277 if ( get_qr(qr_BRANGPICKUP) ) tempitem.flags |= ITEM_FLAG4;
9245 277 else tempitem.flags &= ~ ITEM_FLAG4;
9246 277 }
9247
2/2
✓ Branch 0 taken 23225 times.
✓ Branch 1 taken 107 times.
23332 else if(tempitem.family == itype_wand)
9248 {
9249
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 105 times.
107 if ( get_qr(qr_NOWANDMELEE) ) tempitem.flags |= ITEM_FLAG3;
9250 105 else tempitem.flags &= ~ ITEM_FLAG3;
9251 107 }
9252 23808 }
9253
9254 //Port quest rules to items
9255
2/2
✓ Branch 0 taken 9728 times.
✓ Branch 1 taken 23808 times.
33536 if( s_version <= 37)
9256 {
9257
2/2
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 23715 times.
23808 if(tempitem.family == itype_flippers)
9258 {
9259
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 93 times.
93 if ( (get_qr(qr_NODIVING)) ) tempitem.flags |= ITEM_FLAG1;
9260 93 else tempitem.flags &= ~ ITEM_FLAG1;
9261 93 }
9262
2/2
✓ Branch 0 taken 15904 times.
✓ Branch 1 taken 7811 times.
23715 else if(tempitem.family == itype_sword)
9263 {
9264
2/2
✓ Branch 0 taken 69 times.
✓ Branch 1 taken 7742 times.
7811 if ( (get_qr(qr_QUICKSWORD)) ) tempitem.flags |= ITEM_FLAG5;
9265 7742 else tempitem.flags &= ~ ITEM_FLAG5;
9266 7811 }
9267
2/2
✓ Branch 0 taken 107 times.
✓ Branch 1 taken 15797 times.
15904 else if(tempitem.family == itype_wand)
9268 {
9269
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 104 times.
107 if ( (get_qr(qr_QUICKSWORD)) ) tempitem.flags |= ITEM_FLAG5;
9270 104 else tempitem.flags &= ~ ITEM_FLAG5;
9271 107 }
9272
4/4
✓ Branch 0 taken 15690 times.
✓ Branch 1 taken 107 times.
✓ Branch 2 taken 222 times.
✓ Branch 3 taken 15468 times.
15797 else if(tempitem.family == itype_book || tempitem.family == itype_candle)
9273 {
9274 //@Emily: What was qrFIREPROOFHERO2 again, and does that also need to enable this?
9275
2/2
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 257 times.
329 if ( (get_qr(qr_FIREPROOFHERO)) ) tempitem.flags |= ITEM_FLAG3;
9276 257 else tempitem.flags &= ~ ITEM_FLAG3;
9277 329 }
9278 23808 }
9279
9280
2/2
✓ Branch 0 taken 9728 times.
✓ Branch 1 taken 23808 times.
33536 if( s_version < 38)
9281 {
9282
4/4
✓ Branch 0 taken 23531 times.
✓ Branch 1 taken 277 times.
✓ Branch 2 taken 184 times.
✓ Branch 3 taken 23347 times.
23808 if(tempitem.family == itype_brang || tempitem.family == itype_hookshot)
9283 {
9284
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 461 times.
461 if(get_qr(qr_BRANGPICKUP)) tempitem.flags |= ITEM_FLAG4;
9285 461 else tempitem.flags &= ~ITEM_FLAG4;
9286
9287
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 450 times.
461 if(get_qr(qr_Z3BRANG_HSHOT)) tempitem.flags |= ITEM_FLAG5 | ITEM_FLAG6;
9288 450 else tempitem.flags &= ~(ITEM_FLAG5|ITEM_FLAG6);
9289 461 }
9290
2/2
✓ Branch 0 taken 23073 times.
✓ Branch 1 taken 274 times.
23347 else if(tempitem.family == itype_arrow)
9291 {
9292
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 274 times.
274 if(get_qr(qr_BRANGPICKUP)) tempitem.flags |= ITEM_FLAG4;
9293 274 else tempitem.flags &= ~ITEM_FLAG4;
9294
9295
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 270 times.
274 if(get_qr(qr_Z3BRANG_HSHOT)) tempitem.flags &= ~ITEM_FLAG2;
9296 270 else tempitem.flags |= ITEM_FLAG2;
9297 274 }
9298 23808 }
9299
9300
2/2
✓ Branch 0 taken 9728 times.
✓ Branch 1 taken 23808 times.
33536 if( s_version < 39)
9301 {
9302
6/6
✓ Branch 0 taken 23716 times.
✓ Branch 1 taken 92 times.
✓ Branch 2 taken 23609 times.
✓ Branch 3 taken 107 times.
✓ Branch 4 taken 222 times.
✓ Branch 5 taken 23387 times.
23808 if(tempitem.family == itype_divinefire || tempitem.family == itype_book || tempitem.family == itype_candle)
9303 {
9304
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 409 times.
421 if(get_qr(qr_TEMPCANDLELIGHT)) tempitem.flags |= ITEM_FLAG5;
9305 409 else tempitem.flags &= ~ITEM_FLAG5;
9306 421 }
9307
2/2
✓ Branch 0 taken 183 times.
✓ Branch 1 taken 23204 times.
23387 else if(tempitem.family == itype_potion)
9308 {
9309
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 159 times.
183 if(get_qr(qr_NONBUBBLEMEDICINE))
9310 {
9311 24 tempitem.flags &= ~(ITEM_FLAG3|ITEM_FLAG4);
9312 24 }
9313 else
9314 {
9315 159 tempitem.flags |= ITEM_FLAG3;
9316
2/2
✓ Branch 0 taken 85 times.
✓ Branch 1 taken 74 times.
159 if(get_qr(qr_ITEMBUBBLE))tempitem.flags |= ITEM_FLAG4;
9317 74 else tempitem.flags &= ~ITEM_FLAG4;
9318 }
9319 183 }
9320
2/2
✓ Branch 0 taken 23020 times.
✓ Branch 1 taken 184 times.
23204 else if(tempitem.family == itype_triforcepiece)
9321 {
9322
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 154 times.
184 if(get_qr(qr_NONBUBBLETRIFORCE))
9323 {
9324 30 tempitem.flags |= ITEM_FLAG3;
9325
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 24 times.
30 if(get_qr(qr_ITEMBUBBLE))tempitem.flags |= ITEM_FLAG4;
9326 24 else tempitem.flags &= ~ITEM_FLAG4;
9327 30 }
9328 else
9329 {
9330 154 tempitem.flags &= ~(ITEM_FLAG3|ITEM_FLAG4);
9331 }
9332 184 }
9333 23808 }
9334
9335
2/2
✓ Branch 0 taken 9728 times.
✓ Branch 1 taken 23808 times.
33536 if( s_version < 40)
9336 {
9337
4/4
✓ Branch 0 taken 23506 times.
✓ Branch 1 taken 302 times.
✓ Branch 2 taken 93 times.
✓ Branch 3 taken 23413 times.
23808 if(tempitem.family == itype_ring || tempitem.family == itype_perilring)
9338 {
9339
2/2
✓ Branch 0 taken 47 times.
✓ Branch 1 taken 348 times.
395 if(get_qr(qr_RINGAFFECTDAMAGE))tempitem.flags |= ITEM_FLAG1;
9340 348 else tempitem.flags &= ~ITEM_FLAG1;
9341 395 }
9342
8/8
✓ Branch 0 taken 23191 times.
✓ Branch 1 taken 222 times.
✓ Branch 2 taken 15380 times.
✓ Branch 3 taken 7811 times.
✓ Branch 4 taken 15273 times.
✓ Branch 5 taken 107 times.
✓ Branch 6 taken 92 times.
✓ Branch 7 taken 15181 times.
23413 else if(tempitem.family == itype_candle || tempitem.family == itype_sword || tempitem.family == itype_wand || tempitem.family == itype_cbyrna)
9343 {
9344
2/2
✓ Branch 0 taken 81 times.
✓ Branch 1 taken 8151 times.
8232 if(get_qr(qr_SLASHFLIPFIX))tempitem.flags |= ITEM_FLAG8;
9345 8151 else tempitem.flags &= ~ITEM_FLAG8;
9346 8232 }
9347
6/6
✓ Branch 0 taken 15997 times.
✓ Branch 1 taken 7811 times.
✓ Branch 2 taken 15890 times.
✓ Branch 3 taken 107 times.
✓ Branch 4 taken 93 times.
✓ Branch 5 taken 15797 times.
23808 if(tempitem.family == itype_sword || tempitem.family == itype_wand || tempitem.family == itype_hammer)
9348 {
9349
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8011 times.
8011 if(get_qr(qr_NOITEMMELEE))tempitem.flags |= ITEM_FLAG7;
9350 8011 else tempitem.flags &= ~ITEM_FLAG7;
9351 8011 }
9352
2/2
✓ Branch 0 taken 15705 times.
✓ Branch 1 taken 92 times.
15797 else if(tempitem.family == itype_cbyrna)
9353 {
9354 92 tempitem.flags |= ITEM_FLAG7;
9355 92 }
9356 23808 }
9357
9358
2/2
✓ Branch 0 taken 9728 times.
✓ Branch 1 taken 23808 times.
33536 if( s_version < 41 )
9359 {
9360
2/2
✓ Branch 0 taken 15997 times.
✓ Branch 1 taken 7811 times.
23808 if(tempitem.family == itype_sword)
9361 {
9362
2/2
✓ Branch 0 taken 69 times.
✓ Branch 1 taken 7742 times.
7811 if(get_qr(qr_SWORDMIRROR))tempitem.flags |= ITEM_FLAG9;
9363 7742 else tempitem.flags &= ~ITEM_FLAG9;
9364
9365
2/2
✓ Branch 0 taken 69 times.
✓ Branch 1 taken 7742 times.
7811 if(get_qr(qr_SLOWCHARGINGWALK))tempitem.flags |= ITEM_FLAG10;
9366 7742 else tempitem.flags &= ~ITEM_FLAG10;
9367 7811 }
9368 23808 }
9369
9370
2/2
✓ Branch 0 taken 9728 times.
✓ Branch 1 taken 23808 times.
33536 if( s_version < 42 )
9371 {
9372
2/2
✓ Branch 0 taken 107 times.
✓ Branch 1 taken 23701 times.
23808 if(tempitem.family == itype_wand)
9373 {
9374
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 105 times.
107 if(get_qr(qr_NOWANDMELEE))tempitem.flags |= ITEM_FLAG3;
9375 105 else tempitem.flags &= ~ITEM_FLAG3;
9376
9377 107 tempitem.flags &= ~ITEM_FLAG6;
9378 107 }
9379
2/2
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 23608 times.
23701 else if(tempitem.family == itype_hammer)
9380 {
9381 93 tempitem.flags &= ~ITEM_FLAG3;
9382 93 }
9383
2/2
✓ Branch 0 taken 92 times.
✓ Branch 1 taken 23516 times.
23608 else if(tempitem.family == itype_cbyrna)
9384 {
9385 92 tempitem.flags |= ITEM_FLAG3;
9386
9387 92 tempitem.flags &= ~ITEM_FLAG6;
9388 92 }
9389
2/2
✓ Branch 0 taken 15705 times.
✓ Branch 1 taken 7811 times.
23516 else if(tempitem.family == itype_sword)
9390 {
9391
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7811 times.
7811 if(get_qr(qr_MELEEMAGICCOST))tempitem.flags |= ITEM_FLAG6;
9392 7811 else tempitem.flags &= ~ITEM_FLAG6;
9393 7811 }
9394 23808 }
9395
9396
2/2
✓ Branch 0 taken 9728 times.
✓ Branch 1 taken 23808 times.
33536 if( s_version < 43 )
9397 {
9398
2/2
✓ Branch 0 taken 23670 times.
✓ Branch 1 taken 138 times.
23808 if(tempitem.family == itype_whistle)
9399 {
9400
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 135 times.
138 if(get_qr(qr_WHIRLWINDMIRROR))tempitem.flags |= ITEM_FLAG3;
9401 135 else tempitem.flags &= ~ITEM_FLAG3;
9402 138 }
9403 23808 }
9404
9405
2/2
✓ Branch 0 taken 9728 times.
✓ Branch 1 taken 23808 times.
33536 if( s_version < 45 )
9406 {
9407
2/2
✓ Branch 0 taken 23715 times.
✓ Branch 1 taken 93 times.
23808 if(tempitem.family == itype_flippers)
9408 {
9409 93 tempitem.misc1 = 50; //Dive length, default 50 frames -V
9410 93 tempitem.misc2 = 30; //Dive cooldown, default 30 frames -V
9411 93 }
9412 23808 }
9413
9414
2/2
✓ Branch 0 taken 9728 times.
✓ Branch 1 taken 23808 times.
33536 if( s_version < 46 )
9415 {
9416
2/2
✓ Branch 0 taken 23716 times.
✓ Branch 1 taken 92 times.
23808 if(tempitem.family == itype_raft)
9417 {
9418 92 tempitem.misc1 = 1; //Rafting speed modifier; default 1. Negative slows, positive speeds.
9419 92 }
9420 23808 }
9421
2/2
✓ Branch 0 taken 9728 times.
✓ Branch 1 taken 23808 times.
33536 if ( s_version < 34 ) //! set the default counter for older quests.
9422 {
9423
2/2
✓ Branch 0 taken 75 times.
✓ Branch 1 taken 23733 times.
23808 if ( (tempitem.flags & ITEM_RUPEE_MAGIC) )
9424 {
9425 75 tempitem.cost_counter[0] = 1;
9426 75 }
9427 else
9428 {
9429
2/2
✓ Branch 0 taken 4608 times.
✓ Branch 1 taken 19125 times.
23733 if(get_qr(qr_ENABLEMAGIC))
9430 4608 tempitem.cost_counter[0] = 4;
9431 else
9432 {
9433 19125 tempitem.cost_amount[0] = 0;
9434 19125 tempitem.cost_counter[0] = -1;
9435 }
9436 }
9437 23808 }
9438
9439
2/2
✓ Branch 0 taken 9728 times.
✓ Branch 1 taken 23808 times.
33536 if ( s_version < 35 ) //new Lens of Truth flags
9440 {
9441
2/2
✓ Branch 0 taken 23716 times.
✓ Branch 1 taken 92 times.
23808 if ( tempitem.family == itype_lens )
9442 {
9443
2/2
✓ Branch 0 taken 89 times.
✓ Branch 1 taken 3 times.
92 if ( get_qr(qr_RAFTLENS) )
9444 {
9445 3 tempitem.flags |= ITEM_FLAG4;
9446 3 }
9447
2/2
✓ Branch 0 taken 40 times.
✓ Branch 1 taken 52 times.
92 if ( get_qr(qr_LENSHINTS) )
9448 {
9449 52 tempitem.flags |= ITEM_FLAG1;
9450 52 }
9451
2/2
✓ Branch 0 taken 88 times.
✓ Branch 1 taken 4 times.
92 if ( get_qr(qr_LENSSEESENEMIES) )
9452 {
9453 4 tempitem.flags |= ITEM_FLAG5;
9454 4 }
9455 92 }
9456 23808 }
9457
2/2
✓ Branch 0 taken 9728 times.
✓ Branch 1 taken 23808 times.
33536 if ( s_version < 44 ) //InitD Labels and Sprite Script Data
9458 {
9459
2/2
✓ Branch 0 taken 190464 times.
✓ Branch 1 taken 23808 times.
214272 for ( int32_t q = 0; q < 8; q++ )
9460 {
9461 190464 sprintf(tempitem.initD_label[q],"InitD[%d]",q);
9462 190464 sprintf(tempitem.weapon_initD_label[q],"InitD[%d]",q);
9463 190464 sprintf(tempitem.sprite_initD_label[q],"InitD[%d]",q);
9464 190464 tempitem.sprite_initiald[q] = 0;
9465 190464 }
9466
2/2
✓ Branch 0 taken 47616 times.
✓ Branch 1 taken 23808 times.
71424 for ( int32_t q = 0; q < 2; q++ ) tempitem.sprite_initiala[q] = 0;
9467 23808 tempitem.sprite_script = 0;
9468 23808 }
9469
2/2
✓ Branch 0 taken 9728 times.
✓ Branch 1 taken 23808 times.
33536 if ( s_version < 47 ) //InitD Labels and Sprite Script Data
9470 {
9471 23808 tempitem.pickupflag = 0;
9472 23808 }
9473
9474
2/2
✓ Branch 0 taken 9728 times.
✓ Branch 1 taken 23808 times.
33536 if( s_version < 51 )
9475 {
9476
2/2
✓ Branch 0 taken 23586 times.
✓ Branch 1 taken 222 times.
23808 if( tempitem.family == itype_candle )
9477 {
9478 222 tempitem.misc4 = 50; //Step speed
9479 222 }
9480 23808 }
9481
9482
2/2
✓ Branch 0 taken 9728 times.
✓ Branch 1 taken 23808 times.
33536 if( s_version < 52 )
9483 {
9484
2/2
✓ Branch 0 taken 23525 times.
✓ Branch 1 taken 283 times.
23808 if( tempitem.family == itype_shield )
9485 283 tempitem.flags |= ITEM_FLAG1; //'Block Front' flag
9486 23808 }
9487
2/2
✓ Branch 0 taken 9728 times.
✓ Branch 1 taken 23808 times.
33536 if(s_version < 53)
9488 {
9489
4/4
✓ Branch 0 taken 23335 times.
✓ Branch 1 taken 274 times.
✓ Branch 2 taken 107 times.
✓ Branch 3 taken 92 times.
23808 switch(tempitem.family)
9490 {
9491 case itype_arrow:
9492 274 tempitem.cost_counter[1] = crARROWS;
9493 274 tempitem.cost_amount[1] = 1;
9494 274 break;
9495 case itype_bomb:
9496 107 tempitem.cost_counter[1] = crBOMBS;
9497 107 tempitem.cost_amount[1] = 1;
9498 107 break;
9499 case itype_sbomb:
9500 92 tempitem.cost_counter[1] = crSBOMBS;
9501 92 tempitem.cost_amount[1] = 1;
9502 92 break;
9503 default:
9504 23335 tempitem.cost_counter[1] = crNONE;
9505 23335 tempitem.cost_amount[1] = 0;
9506 23335 }
9507 23808 tempitem.magiccosttimer[1] = 0;
9508 23808 }
9509
2/2
✓ Branch 0 taken 8448 times.
✓ Branch 1 taken 25088 times.
33536 if( s_version < 54 )
9510 {
9511
2/2
✓ Branch 0 taken 24989 times.
✓ Branch 1 taken 99 times.
25088 if( tempitem.family == itype_flippers )
9512 99 tempitem.misc3 = INT_BTN_A; //'Block Front' flag
9513 25088 }
9514
2/2
✓ Branch 0 taken 8448 times.
✓ Branch 1 taken 25088 times.
33536 if(s_version < 55)
9515 {
9516
3/3
✓ Branch 0 taken 194 times.
✓ Branch 1 taken 194 times.
✓ Branch 2 taken 24700 times.
25088 switch(tempitem.family)
9517 {
9518 case itype_spinscroll:
9519 case itype_quakescroll:
9520 194 tempitem.usesound2 = WAV_ZN1CHARGE;
9521 194 break;
9522 case itype_spinscroll2:
9523 case itype_quakescroll2:
9524 194 tempitem.usesound2 = WAV_ZN1CHARGE2;
9525 194 break;
9526 }
9527 25088 }
9528
2/2
✓ Branch 0 taken 8448 times.
✓ Branch 1 taken 25088 times.
33536 if(s_version < 56)
9529 {
9530
4/4
✓ Branch 0 taken 24645 times.
✓ Branch 1 taken 97 times.
✓ Branch 2 taken 234 times.
✓ Branch 3 taken 112 times.
25088 switch(tempitem.family)
9531 {
9532 case itype_divinefire:
9533
2/2
✓ Branch 0 taken 92 times.
✓ Branch 1 taken 5 times.
97 SETFLAG(tempitem.flags, ITEM_FLAG9, version < 0x255); //Strong Fire
9534
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 81 times.
97 SETFLAG(tempitem.flags, ITEM_FLAG10, version < 0x250); //Magic Fire
9535 97 tempitem.flags |= ITEM_FLAG11; //Divine Fire
9536 97 break;
9537 case itype_candle:
9538
2/2
✓ Branch 0 taken 114 times.
✓ Branch 1 taken 120 times.
234 SETFLAG(tempitem.flags, ITEM_FLAG9, tempitem.fam_type > 1); //Strong Fire
9539 234 tempitem.flags &= ~ITEM_FLAG10; //Magic Fire
9540 234 tempitem.flags &= ~ITEM_FLAG11; //Divine Fire
9541 234 break;
9542 case itype_book:
9543 112 tempitem.flags |= ITEM_FLAG9; //Strong Fire
9544 112 tempitem.flags |= ITEM_FLAG10; //Magic Fire
9545 112 tempitem.flags &= ~ITEM_FLAG11; //Divine Fire
9546 112 break;
9547 }
9548 25088 }
9549
9550
2/2
✓ Branch 0 taken 31392 times.
✓ Branch 1 taken 2144 times.
33536 if(tempitem.fam_type==0) // Always do this
9551 2144 tempitem.fam_type=1;
9552
9553 33536 memcpy(&itemsbuf[i], &tempitem, sizeof(itemdata));
9554 33536 }
9555
9556 131 return 0;
9557 131 }
9558
9559 static bool did_init_def_items = false;
9560 67264 void init_def_items()
9561 {
9562
2/2
✓ Branch 0 taken 67147 times.
✓ Branch 1 taken 117 times.
67264 if(did_init_def_items) return;
9563 117 did_init_def_items = true;
9564 117 default_items[3].cost_counter[1] = crBOMBS;
9565 117 default_items[13].cost_counter[1] = crARROWS;
9566 117 default_items[14].cost_counter[1] = crARROWS;
9567 117 default_items[48].cost_counter[1] = crSBOMBS;
9568 117 default_items[57].cost_counter[1] = crARROWS;
9569 67264 }
9570 67264 void reset_itembuf(itemdata *item, int32_t id)
9571 {
9572 67264 init_def_items();
9573
2/2
✓ Branch 0 taken 28702 times.
✓ Branch 1 taken 38562 times.
67264 if(id<iLast)
9574 {
9575 // Copy everything *EXCEPT* the tile, misc, cset, frames, speed, delay and ltm.
9576 38562 word tile = item->tile;
9577 38562 byte miscs = item->misc_flags, cset = item->csets, frames = item->frames, speed = item->speed, delay = item->delay;
9578 38562 int32_t ltm = item->ltm;
9579
9580 38562 memcpy(item,&default_items[id],sizeof(itemdata));
9581 38562 item->tile = tile;
9582 38562 item->misc_flags = miscs;
9583 38562 item->csets = cset;
9584 38562 item->frames = frames;
9585 38562 item->speed = speed;
9586 38562 item->delay = delay;
9587 38562 item->ltm = ltm;
9588 38562 }
9589 67264 }
9590
9591 34048 void reset_itemname(int32_t id)
9592 {
9593 34048 sprintf(item_string[id],"zz%03d",id);
9594
9595
2/2
✓ Branch 0 taken 15029 times.
✓ Branch 1 taken 19019 times.
34048 if(id < iLast)
9596 19019 strcpy(item_string[id],old_item_string[id]);
9597 34048 }
9598
9599 131 int32_t readweapons(PACKFILE *f, zquestheader *Header)
9600 {
9601
2/2
✓ Branch 0 taken 127 times.
✓ Branch 1 taken 4 times.
131 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_weapons);
9602
9603 131 word weapons_to_read=MAXWPNS;
9604 int32_t dummy;
9605 byte padding;
9606 wpndata tempweapon;
9607 131 word s_version=0, s_cversion=0;
9608
9609
9610
1/2
✓ Branch 0 taken 131 times.
✗ Branch 1 not taken.
131 if(Header->zelda_version < 0x186)
9611 {
9612 weapons_to_read=64;
9613 }
9614
9615
1/2
✓ Branch 0 taken 131 times.
✗ Branch 1 not taken.
131 if(Header->zelda_version < 0x185)
9616 {
9617 weapons_to_read=32;
9618 }
9619
9620
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 127 times.
131 if(Header->zelda_version > 0x192)
9621 {
9622 127 weapons_to_read=0;
9623
9624 //section version info
9625
1/2
✓ Branch 0 taken 127 times.
✗ Branch 1 not taken.
127 if(!p_igetw(&s_version,f))
9626 {
9627 return qe_invalid;
9628 }
9629
9630 127 FFCore.quest_format[vWeaponSprites] = s_version;
9631
9632 //al_trace("Weapons version %d\n", s_version);
9633
1/2
✓ Branch 0 taken 127 times.
✗ Branch 1 not taken.
127 if(!p_igetw(&s_cversion,f))
9634 {
9635 return qe_invalid;
9636 }
9637
9638 //section size
9639
1/2
✓ Branch 0 taken 127 times.
✗ Branch 1 not taken.
127 if(!p_igetl(&dummy,f))
9640 {
9641 return qe_invalid;
9642 }
9643
9644 //finally... section data
9645
1/2
✓ Branch 0 taken 127 times.
✗ Branch 1 not taken.
127 if(!p_igetw(&weapons_to_read,f))
9646 {
9647 return qe_invalid;
9648 }
9649
9650
2/4
✓ Branch 0 taken 127 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 127 times.
127 if (!(weapons_to_read >= 0 && weapons_to_read <= MAXWPNS))
9651 {
9652 return qe_invalid;
9653 }
9654 127 }
9655
9656
2/2
✓ Branch 0 taken 115 times.
✓ Branch 1 taken 16 times.
131 if(s_version>2)
9657 {
9658
2/2
✓ Branch 0 taken 29440 times.
✓ Branch 1 taken 115 times.
29555 for(int32_t i=0; i<weapons_to_read; i++)
9659 {
9660 char tempname[64];
9661
9662
1/2
✓ Branch 0 taken 29440 times.
✗ Branch 1 not taken.
29440 if(!pfread(tempname, 64, f))
9663 {
9664 return qe_invalid;
9665 }
9666
9667 29440 weapon_string[i][0] = '\0';
9668 29440 strncat(weapon_string[i], tempname, 64 - 1);
9669 29440 }
9670
9671
1/2
✓ Branch 0 taken 115 times.
✗ Branch 1 not taken.
115 if(s_version<4)
9672 {
9673 strcpy(weapon_string[iwHover],old_weapon_string[iwHover]);
9674 strcpy(weapon_string[wFIREMAGIC],old_weapon_string[wFIREMAGIC]);
9675 }
9676
9677
1/2
✓ Branch 0 taken 115 times.
✗ Branch 1 not taken.
115 if(s_version<5)
9678 {
9679 strcpy(weapon_string[iwQuarterHearts],old_weapon_string[iwQuarterHearts]);
9680 }
9681
9682 /*
9683 if (s_version<6)
9684 {
9685 strcpy(weapon_string[iwSideRaft],old_weapon_string[iwSideRaft]);
9686 strcpy(weapon_string[iwSideLadder],old_weapon_string[iwSideLadder]);
9687 }
9688 */
9689 115 }
9690
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 else if (!should_skip)
9691 {
9692
2/2
✓ Branch 0 taken 4096 times.
✓ Branch 1 taken 16 times.
4112 for(int32_t i=0; i<MAXWPNS; i++)
9693 4096 reset_weaponname(i);
9694 16 }
9695
9696
2/2
✓ Branch 0 taken 31280 times.
✓ Branch 1 taken 131 times.
31411 for(int32_t i=0; i<weapons_to_read; i++)
9697 {
9698 31280 word oldtile = 0;
9699
2/2
✓ Branch 0 taken 9216 times.
✓ Branch 1 taken 22064 times.
31280 if (s_version < 8)
9700 {
9701
1/2
✓ Branch 0 taken 22064 times.
✗ Branch 1 not taken.
22064 if (!p_igetw(&oldtile, f))
9702 return qe_invalid;
9703 22064 }
9704
9705
1/2
✓ Branch 0 taken 31280 times.
✗ Branch 1 not taken.
31280 if(!p_getc(&tempweapon.misc,f))
9706 {
9707 return qe_invalid;
9708 }
9709
9710
1/2
✓ Branch 0 taken 31280 times.
✗ Branch 1 not taken.
31280 if(!p_getc(&tempweapon.csets,f))
9711 {
9712 return qe_invalid;
9713 }
9714
9715
1/2
✓ Branch 0 taken 31280 times.
✗ Branch 1 not taken.
31280 if(!p_getc(&tempweapon.frames,f))
9716 {
9717 return qe_invalid;
9718 }
9719
9720
1/2
✓ Branch 0 taken 31280 times.
✗ Branch 1 not taken.
31280 if(!p_getc(&tempweapon.speed,f))
9721 {
9722 return qe_invalid;
9723 }
9724
9725
1/2
✓ Branch 0 taken 31280 times.
✗ Branch 1 not taken.
31280 if(!p_getc(&tempweapon.type,f))
9726 {
9727 return qe_invalid;
9728 }
9729
9730
2/2
✓ Branch 0 taken 21552 times.
✓ Branch 1 taken 9728 times.
31280 if ( s_version >= 7 )
9731 {
9732
1/2
✓ Branch 0 taken 9728 times.
✗ Branch 1 not taken.
9728 if(!p_igetw(&tempweapon.script,f))
9733 {
9734 return qe_invalid;
9735 }
9736
1/2
✓ Branch 0 taken 9728 times.
✗ Branch 1 not taken.
9728 if(!p_igetl(&tempweapon.tile,f))
9737 {
9738 return qe_invalid;
9739 }
9740 9728 }
9741
2/2
✓ Branch 0 taken 9728 times.
✓ Branch 1 taken 21552 times.
31280 if ( s_version < 7 )
9742 {
9743 21552 tempweapon.tile = oldtile;
9744 21552 }
9745
9746
2/2
✓ Branch 0 taken 30256 times.
✓ Branch 1 taken 1024 times.
31280 if(Header->zelda_version < 0x193)
9747 {
9748
1/2
✓ Branch 0 taken 1024 times.
✗ Branch 1 not taken.
1024 if(!p_getc(&padding,f))
9749 {
9750 return qe_invalid;
9751 }
9752 1024 }
9753
9754
2/2
✓ Branch 0 taken 29440 times.
✓ Branch 1 taken 1840 times.
31280 if(s_version < 6)
9755 {
9756
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1836 times.
1840 if(i==ewFIRETRAIL)
9757 {
9758 4 tempweapon.misc |= WF_BEHIND;
9759 4 }
9760 else
9761 1836 tempweapon.misc &= ~WF_BEHIND;
9762 1840 }
9763
9764
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 31280 times.
31280 if (!should_skip)
9765 31280 memcpy(&wpnsbuf[i], &tempweapon, sizeof(tempweapon));
9766 31280 }
9767
9768
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 131 times.
131 if (should_skip)
9769 return 0;
9770
9771
2/2
✓ Branch 0 taken 115 times.
✓ Branch 1 taken 16 times.
131 if(s_version<2)
9772 {
9773 16 wpnsbuf[wSBOOM]=wpnsbuf[wBOOM];
9774 16 }
9775
9776
2/2
✓ Branch 0 taken 115 times.
✓ Branch 1 taken 16 times.
131 if(s_version<5)
9777 {
9778 16 wpnsbuf[iwQuarterHearts].tile=1;
9779 16 wpnsbuf[iwQuarterHearts].csets=1;
9780 16 }
9781
9782
1/2
✓ Branch 0 taken 131 times.
✗ Branch 1 not taken.
131 if(Header->zelda_version < 0x176)
9783 {
9784 wpnsbuf[iwSpawn] = *((wpndata*)(itemsbuf + iMisc1));
9785 wpnsbuf[iwDeath] = *((wpndata*)(itemsbuf + iMisc2));
9786 memset(&itemsbuf[iMisc1],0,sizeof(itemdata));
9787 memset(&itemsbuf[iMisc2],0,sizeof(itemdata));
9788 }
9789
9790
2/4
✓ Branch 0 taken 127 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
131 if((Header->zelda_version < 0x192)||
9791
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 127 times.
127 ((Header->zelda_version == 0x192)&&(Header->build<129)))
9792 {
9793 4 wpnsbuf[wHSCHAIN_V] = wpnsbuf[wHSCHAIN_H];
9794 4 }
9795
9796
2/2
✓ Branch 0 taken 127 times.
✓ Branch 1 taken 4 times.
131 if((Header->zelda_version < 0x210))
9797 {
9798 4 wpnsbuf[wLSHEAD] = wpnsbuf[wHSHEAD];
9799 4 wpnsbuf[wLSCHAIN_H] = wpnsbuf[wHSCHAIN_H];
9800 4 wpnsbuf[wLSHANDLE] = wpnsbuf[wHSHANDLE];
9801 4 wpnsbuf[wLSCHAIN_V] = wpnsbuf[wHSCHAIN_V];
9802 4 }
9803
9804 131 return 0;
9805 131 }
9806
9807 131 void init_guys(int32_t guyversion)
9808 {
9809
2/2
✓ Branch 0 taken 67072 times.
✓ Branch 1 taken 131 times.
67203 for(int32_t i=0; i<MAXGUYS; i++)
9810 {
9811 67072 guysbuf[i] = default_guys[0];
9812 67072 }
9813
9814
2/2
✓ Branch 0 taken 23187 times.
✓ Branch 1 taken 131 times.
23318 for(int32_t i=0; i<OLDMAXGUYS; i++)
9815 {
9816 23187 guysbuf[i] = default_guys[i];
9817
2/2
✓ Branch 0 taken 22925 times.
✓ Branch 1 taken 262 times.
23187 guysbuf[i].spr_shadow = (guysbuf[i].family==eeROCK && guysbuf[i].misc10==1) ? iwLargeShadow : iwShadow;
9818 23187 guysbuf[i].spr_death = iwDeath;
9819 23187 guysbuf[i].spr_spawn = iwSpawn;
9820 // Patra fix: 2.10 BSPatras used spDIG. 2.50 Patras use CSet 7.
9821
4/4
✓ Branch 0 taken 2832 times.
✓ Branch 1 taken 20355 times.
✓ Branch 2 taken 2816 times.
✓ Branch 3 taken 16 times.
23187 if(guyversion<=3 && i==ePATRABS)
9822 {
9823 16 guysbuf[i].bosspal=spDIG;
9824 16 guysbuf[i].cset=14;
9825 16 guysbuf[i].misc9=14;
9826 16 }
9827
9828
2/2
✓ Branch 0 taken 20355 times.
✓ Branch 1 taken 2832 times.
23187 if(guyversion<=3)
9829 {
9830 // Rope/Ghini Flash rules
9831
2/2
✓ Branch 0 taken 708 times.
✓ Branch 1 taken 2124 times.
2832 if(get_bit(deprecated_rules, qr_NOROPE2FLASH_DEP))
9832 {
9833
2/2
✓ Branch 0 taken 2112 times.
✓ Branch 1 taken 12 times.
2124 if(i==eROPE2)
9834 {
9835 12 guysbuf[i].flags2 &= ~guy_flashing;
9836 12 }
9837 2124 }
9838
9839
2/2
✓ Branch 0 taken 2301 times.
✓ Branch 1 taken 531 times.
2832 if(get_bit(deprecated_rules, qr_NOBUBBLEFLASH_DEP))
9840 {
9841
12/12
✓ Branch 0 taken 528 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 525 times.
✓ Branch 3 taken 3 times.
✓ Branch 4 taken 522 times.
✓ Branch 5 taken 3 times.
✓ Branch 6 taken 519 times.
✓ Branch 7 taken 3 times.
✓ Branch 8 taken 516 times.
✓ Branch 9 taken 3 times.
✓ Branch 10 taken 3 times.
✓ Branch 11 taken 513 times.
531 if(i==eBUBBLEST || i==eBUBBLESP || i==eBUBBLESR || i==eBUBBLEIT || i==eBUBBLEIP || i==eBUBBLEIR)
9842 {
9843 18 guysbuf[i].flags2 &= ~guy_flashing;
9844 18 }
9845 531 }
9846
9847
2/2
✓ Branch 0 taken 2816 times.
✓ Branch 1 taken 16 times.
2832 if(i==eGHINI2)
9848 {
9849
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 3 times.
16 if(get_bit(deprecated_rules, qr_GHINI2BLINK_DEP))
9850 {
9851 3 guysbuf[i].flags2 |= guy_blinking;
9852 3 }
9853
9854
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(get_bit(deprecated_rules, qr_PHANTOMGHINI2_DEP))
9855 {
9856 guysbuf[i].flags2 |= guy_transparent;
9857 }
9858 16 }
9859 2832 }
9860
9861 // Darknut fix
9862
10/10
✓ Branch 0 taken 23056 times.
✓ Branch 1 taken 131 times.
✓ Branch 2 taken 22925 times.
✓ Branch 3 taken 131 times.
✓ Branch 4 taken 22794 times.
✓ Branch 5 taken 131 times.
✓ Branch 6 taken 22663 times.
✓ Branch 7 taken 131 times.
✓ Branch 8 taken 131 times.
✓ Branch 9 taken 22532 times.
23187 if(i==eDKNUT1 || i==eDKNUT2 || i==eDKNUT3 || i==eDKNUT4 || i==eDKNUT5)
9863 {
9864
2/2
✓ Branch 0 taken 445 times.
✓ Branch 1 taken 210 times.
655 if(get_qr(qr_NEWENEMYTILES))
9865 {
9866 445 guysbuf[i].s_tile=guysbuf[i].e_tile+120;
9867 445 guysbuf[i].s_width=guysbuf[i].e_width;
9868 445 guysbuf[i].s_height=guysbuf[i].e_height;
9869 445 }
9870 210 else guysbuf[i].s_tile=860;
9871
9872
2/2
✓ Branch 0 taken 575 times.
✓ Branch 1 taken 80 times.
655 if(get_bit(deprecated_rules,qr_BRKBLSHLDS_DEP))
9873 {
9874 80 guysbuf[i].flags |= guy_bkshield;
9875 80 }
9876 655 }
9877
9878
4/4
✓ Branch 0 taken 23056 times.
✓ Branch 1 taken 131 times.
✓ Branch 2 taken 23179 times.
✓ Branch 3 taken 8 times.
23187 if((i==eGELTRIB || i==eFGELTRIB) && get_bit(deprecated_rules,qr_OLDTRIBBLES_DEP))
9879 {
9880 8 guysbuf[i].misc3 = (i==eFGELTRIB ? eFZOL : eZOL);
9881 8 }
9882 23187 }
9883 131 }
9884
9885 4096 void reset_weaponname(int32_t i)
9886 {
9887
2/2
✓ Branch 0 taken 1408 times.
✓ Branch 1 taken 2688 times.
4096 if(i<wLast)
9888 {
9889 1408 strcpy(weapon_string[i],old_weapon_string[i]);
9890 1408 }
9891 else
9892 2688 sprintf(weapon_string[i],"zz%03d",i);
9893 4096 }
9894
9895 131 void init_item_drop_sets()
9896 {
9897
2/2
✓ Branch 0 taken 33536 times.
✓ Branch 1 taken 131 times.
33667 for(int32_t i=0; i<MAXITEMDROPSETS; i++)
9898 {
9899 // item_drop_sets[i] = default_item_drop_sets[0];
9900 33536 memset(&item_drop_sets[i], 0, sizeof(item_drop_object));
9901 33536 }
9902
9903
2/2
✓ Branch 0 taken 1703 times.
✓ Branch 1 taken 131 times.
1834 for(int32_t i=0; i<isMAX; i++)
9904 {
9905 1703 item_drop_sets[i] = default_item_drop_sets[i];
9906
9907 // Deprecated: qr_NOCLOCKS and qr_ALLOW10RUPEEDROPS
9908
2/2
✓ Branch 0 taken 17030 times.
✓ Branch 1 taken 1703 times.
18733 for(int32_t j=0; j<10; ++j)
9909 {
9910 17030 int32_t it = item_drop_sets[i].item[j];
9911
9912
3/4
✓ Branch 0 taken 11960 times.
✓ Branch 1 taken 5070 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 768 times.
17030 if((itemsbuf[it].family == itype_rupee && ((itemsbuf[it].amount)&0xFFF) == 10)
9913
2/2
✓ Branch 0 taken 768 times.
✓ Branch 1 taken 11192 times.
11960 && !get_bit(deprecated_rules, qr_ALLOW10RUPEEDROPS_DEP))
9914 {
9915 768 item_drop_sets[i].chance[j+1]=0;
9916 768 }
9917
3/4
✓ Branch 0 taken 524 times.
✓ Branch 1 taken 15738 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 524 times.
16262 else if(itemsbuf[it].family == itype_clock && get_bit(deprecated_rules, qr_NOCLOCKS_DEP))
9918 {
9919 item_drop_sets[i].chance[j+1]=0;
9920 }
9921
9922 // From Sept 2007 to Dec 2008, non-gameplay items were prohibited.
9923
2/2
✓ Branch 0 taken 17022 times.
✓ Branch 1 taken 8 times.
17030 if(itemsbuf[it].family == itype_misc)
9924 {
9925 // If a non-gameplay item was selected, then item drop was aborted.
9926 // Reflect this by increasing the 'Nothing' chance accordingly.
9927 8 item_drop_sets[i].chance[0]+=item_drop_sets[i].chance[j+1];
9928 8 item_drop_sets[i].chance[j+1]=0;
9929 8 }
9930 17030 }
9931 1703 }
9932 131 }
9933
9934 131 void init_favorites()
9935 {
9936
2/2
✓ Branch 0 taken 165060 times.
✓ Branch 1 taken 131 times.
165191 for(int32_t i=0; i<MAXFAVORITECOMBOS; i++)
9937 {
9938 165060 favorite_combos[i]=-1;
9939 165060 }
9940 131 }
9941
9942 const char *ctype_name[cMAX]=
9943 {
9944 "cNONE", "cSTAIR", "cCAVE", "cWATER", "cARMOS", "cGRAVE", "cDOCK",
9945 "cUNDEF", "cPUSH_WAIT", "cPUSH_HEAVY", "cPUSH_HW", "cL_STATUE", "cR_STATUE",
9946 "cWALKSLOW", "cCVUP", "cCVDOWN", "cCVLEFT", "cCVRIGHT", "cSWIMWARP", "cDIVEWARP",
9947 "cLADDERHOOKSHOT", "cTRIGNOFLAG", "cTRIGFLAG", "cZELDA", "cSLASH", "cSLASHITEM",
9948 "cPUSH_HEAVY2", "cPUSH_HW2", "cPOUND", "cHSGRAB", "cHSBRIDGE", "cDAMAGE1",
9949 "cDAMAGE2", "cDAMAGE3", "cDAMAGE4", "cC_STATUE", "cTRAP_H", "cTRAP_V", "cTRAP_4",
9950 "cTRAP_LR", "cTRAP_UD", "cPIT", "cHOOKSHOTONLY", "cOVERHEAD", "cNOFLYZONE", "cMIRROR",
9951 "cMIRRORSLASH", "cMIRRORBACKSLASH", "cMAGICPRISM", "cMAGICPRISM4",
9952 "cMAGICSPONGE", "cCAVE2", "cEYEBALL_A", "cEYEBALL_B", "cNOJUMPZONE", "cBUSH",
9953 "cFLOWERS", "cTALLGRASS", "cSHALLOWWATER", "cLOCKBLOCK", "cLOCKBLOCK2",
9954 "cBOSSLOCKBLOCK", "cBOSSLOCKBLOCK2", "cLADDERONLY", "cBSGRAVE",
9955 "cCHEST", "cCHEST2", "cLOCKEDCHEST", "cLOCKEDCHEST2", "cBOSSCHEST", "cBOSSCHEST2",
9956 "cRESET", "cSAVE", "cSAVE2", "cCAVEB", "cCAVEC", "cCAVED",
9957 "cSTAIRB", "cSTAIRC", "cSTAIRD", "cPITB", "cPITC", "cPITD",
9958 "cCAVE2B", "cCAVE2C", "cCAVE2D", "cSWIMWARPB", "cSWIMWARPC", "cSWIMWARPD",
9959 "cDIVEWARPB", "cDIVEWARPC", "cDIVEWARPD", "cSTAIRR", "cPITR",
9960 "cAWARPA", "cAWARPB", "cAWARPC", "cAWARPD", "cAWARPR",
9961 "cSWARPA", "cSWARPB", "cSWARPC", "cSWARPD", "cSWARPR", "cSTRIGNOFLAG", "cSTRIGFLAG",
9962 "cSTEP", "cSTEPSAME", "cSTEPALL", "cSTEPCOPY", "cNOENEMY", "cBLOCKARROW1", "cBLOCKARROW2",
9963 "cBLOCKARROW3", "cBLOCKBRANG1", "cBLOCKBRANG2", "cBLOCKBRANG3", "cBLOCKSBEAM", "cBLOCKALL",
9964 "cBLOCKFIREBALL", "cDAMAGE5", "cDAMAGE6", "cDAMAGE7", "cCHANGE", "cSPINTILE1", "cSPINTILE2",
9965 "cSCREENFREEZE", "cSCREENFREEZEFF", "cNOGROUNDENEMY", "cSLASHNEXT", "cSLASHNEXTITEM", "cBUSHNEXT"
9966 "cSLASHTOUCHY", "cSLASHITEMTOUCHY", "cBUSHTOUCHY", "cFLOWERSTOUCHY", "cTALLGRASSTOUCHY",
9967 "cSLASHNEXTTOUCHY", "cSLASHNEXTITEMTOUCHY", "cBUSHNEXTTOUCHY", "cEYEBALL_4", "cTALLGRASSNEXT",
9968 "cSCRIPT1", "cSCRIPT2", "cSCRIPT3", "cSCRIPT4", "cSCRIPT5",
9969 "cSCRIPT6", "cSCRIPT7", "cSCRIPT8", "cSCRIPT9", "cSCRIPT10",
9970 "cSCRIPT11", "cSCRIPT12", "cSCRIPT13", "cSCRIPT14", "cSCRIPT15",
9971 "cSCRIPT16", "cSCRIPT17", "cSCRIPT18", "cSCRIPT19", "cSCRIPT20"
9972
9973 };
9974
9975 226 int32_t init_combo_classes()
9976 {
9977
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 226 times.
226 zinfo* zi = (load_tmp_zi ? load_tmp_zi : &ZI);
9978
2/2
✓ Branch 0 taken 41358 times.
✓ Branch 1 taken 226 times.
41584 for(int32_t i=0; i<cMAX; i++)
9979 {
9980 41358 combo_class_buf[i] = default_combo_classes[i];
9981
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 41358 times.
41358 if ( char const* nm = zi->getComboTypeName(i) )
9982 {
9983 41358 size_t len = strlen(nm);
9984
2/2
✓ Branch 0 taken 2646912 times.
✓ Branch 1 taken 41358 times.
2688270 for ( size_t q = 0; q < 64; q++ )
9985 {
9986
2/2
✓ Branch 0 taken 605906 times.
✓ Branch 1 taken 2041006 times.
2646912 combo_class_buf[i].name[q] = (q<len ? nm[q] : 0);
9987 2646912 }
9988 41358 }
9989 41358 }
9990
9991 226 return 0;
9992 }
9993
9994 97 int32_t readherosprites2(PACKFILE *f, int32_t v_herosprites, int32_t cv_herosprites)
9995 {
9996
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 89 times.
97 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_herosprites);
9997
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 97 times.
97 if (should_skip) return 0;
9998
9999
1/2
✓ Branch 0 taken 97 times.
✗ Branch 1 not taken.
97 assert(v_herosprites < 6);
10000 //these are here to bypass compiler warnings about unused arguments
10001 97 cv_herosprites=cv_herosprites;
10002
10003 97 zinit.hero_swim_speed=67; //default
10004 97 setupherotiles(zinit.heroAnimationStyle);
10005 97 setupherodefenses();
10006 97 setupherooffsets();
10007
10008
2/2
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 77 times.
97 if(v_herosprites>=0)
10009 {
10010 word tile, tile2;
10011 byte flip, extend, dummy_byte;
10012
10013
2/2
✓ Branch 0 taken 308 times.
✓ Branch 1 taken 77 times.
385 for(int32_t i=0; i<4; i++)
10014 {
10015
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_igetw(&tile,f))
10016 {
10017 return qe_invalid;
10018 }
10019
10020
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_getc(&flip,f))
10021 {
10022 return qe_invalid;
10023 }
10024
10025
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_getc(&extend,f))
10026 {
10027 return qe_invalid;
10028 }
10029
10030 308 walkspr[i][spr_tile]=(int32_t)tile;
10031 308 walkspr[i][spr_flip]=(int32_t)flip;
10032 308 walkspr[i][spr_extend]=(int32_t)extend;
10033 308 }
10034
10035
2/2
✓ Branch 0 taken 308 times.
✓ Branch 1 taken 77 times.
385 for(int32_t i=0; i<4; i++)
10036 {
10037
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_igetw(&tile,f))
10038 {
10039 return qe_invalid;
10040 }
10041
10042
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_getc(&flip,f))
10043 {
10044 return qe_invalid;
10045 }
10046
10047
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_getc(&extend,f))
10048 {
10049 return qe_invalid;
10050 }
10051
10052 308 stabspr[i][spr_tile]=(int32_t)tile;
10053 308 stabspr[i][spr_flip]=(int32_t)flip;
10054 308 stabspr[i][spr_extend]=(int32_t)extend;
10055 308 }
10056
10057
2/2
✓ Branch 0 taken 308 times.
✓ Branch 1 taken 77 times.
385 for(int32_t i=0; i<4; i++)
10058 {
10059
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_igetw(&tile,f))
10060 {
10061 return qe_invalid;
10062 }
10063
10064
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_getc(&flip,f))
10065 {
10066 return qe_invalid;
10067 }
10068
10069
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_getc(&extend,f))
10070 {
10071 return qe_invalid;
10072 }
10073
10074 308 slashspr[i][spr_tile]=(int32_t)tile;
10075 308 slashspr[i][spr_flip]=(int32_t)flip;
10076 308 slashspr[i][spr_extend]=(int32_t)extend;
10077 308 }
10078
10079
2/2
✓ Branch 0 taken 308 times.
✓ Branch 1 taken 77 times.
385 for(int32_t i=0; i<4; i++)
10080 {
10081
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_igetw(&tile,f))
10082 {
10083 return qe_invalid;
10084 }
10085
10086
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_getc(&flip,f))
10087 {
10088 return qe_invalid;
10089 }
10090
10091
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_getc(&extend,f))
10092 {
10093 return qe_invalid;
10094 }
10095
10096 308 floatspr[i][spr_tile]=(int32_t)tile;
10097 308 floatspr[i][spr_flip]=(int32_t)flip;
10098 308 floatspr[i][spr_extend]=(int32_t)extend;
10099 308 }
10100
10101
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 77 times.
77 if(v_herosprites>1)
10102 {
10103
2/2
✓ Branch 0 taken 308 times.
✓ Branch 1 taken 77 times.
385 for(int32_t i=0; i<4; i++)
10104 {
10105
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_igetw(&tile,f))
10106 {
10107 return qe_invalid;
10108 }
10109
10110
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_getc(&flip,f))
10111 {
10112 return qe_invalid;
10113 }
10114
10115
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_getc(&extend,f))
10116 {
10117 return qe_invalid;
10118 }
10119
10120 308 swimspr[i][spr_tile]=(int32_t)tile;
10121 308 swimspr[i][spr_flip]=(int32_t)flip;
10122 308 swimspr[i][spr_extend]=(int32_t)extend;
10123 308 }
10124 77 }
10125
10126
2/2
✓ Branch 0 taken 308 times.
✓ Branch 1 taken 77 times.
385 for(int32_t i=0; i<4; i++)
10127 {
10128
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_igetw(&tile,f))
10129 {
10130 return qe_invalid;
10131 }
10132
10133
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_getc(&flip,f))
10134 {
10135 return qe_invalid;
10136 }
10137
10138
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_getc(&extend,f))
10139 {
10140 return qe_invalid;
10141 }
10142
10143 308 divespr[i][spr_tile]=(int32_t)tile;
10144 308 divespr[i][spr_flip]=(int32_t)flip;
10145 308 divespr[i][spr_extend]=(int32_t)extend;
10146 308 }
10147
10148
2/2
✓ Branch 0 taken 308 times.
✓ Branch 1 taken 77 times.
385 for(int32_t i=0; i<4; i++)
10149 {
10150
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_igetw(&tile,f))
10151 {
10152 return qe_invalid;
10153 }
10154
10155
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_getc(&flip,f))
10156 {
10157 return qe_invalid;
10158 }
10159
10160
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_getc(&extend,f))
10161 {
10162 return qe_invalid;
10163 }
10164
10165 308 poundspr[i][spr_tile]=(int32_t)tile;
10166 308 poundspr[i][spr_flip]=(int32_t)flip;
10167 308 poundspr[i][spr_extend]=(int32_t)extend;
10168 308 }
10169
10170
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 if(!p_igetw(&tile,f))
10171 {
10172 return qe_invalid;
10173 }
10174
10175 77 flip=0;
10176
10177
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 77 times.
77 if(v_herosprites>0)
10178 {
10179
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 if(!p_getc(&flip,f))
10180 {
10181 return qe_invalid;
10182 }
10183 77 }
10184
10185
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 if(!p_getc(&extend,f))
10186 {
10187 return qe_invalid;
10188 }
10189
10190 77 castingspr[spr_tile]=(int32_t)tile;
10191 77 castingspr[spr_flip]=(int32_t)flip;
10192 77 castingspr[spr_extend]=(int32_t)extend;
10193
10194
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 if(v_herosprites>0)
10195 {
10196 77 int32_t num_holdsprs = (v_herosprites > 6 ? 3 : 2);
10197
2/2
✓ Branch 0 taken 154 times.
✓ Branch 1 taken 77 times.
231 for(int32_t i=0; i<2; i++)
10198 {
10199
2/2
✓ Branch 0 taken 308 times.
✓ Branch 1 taken 154 times.
462 for(int32_t j=0; j<num_holdsprs; j++)
10200 {
10201
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_igetw(&tile,f))
10202 {
10203 return qe_invalid;
10204 }
10205
10206
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_getc(&flip,f))
10207 {
10208 return qe_invalid;
10209 }
10210
10211
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_getc(&extend,f))
10212 {
10213 return qe_invalid;
10214 }
10215
10216 308 holdspr[i][j][spr_tile]=(int32_t)tile;
10217 308 holdspr[i][j][spr_flip]=(int32_t)flip;
10218 308 holdspr[i][j][spr_extend]=(int32_t)extend;
10219 308 }
10220 154 }
10221 77 }
10222 else
10223 {
10224 for(int32_t i=0; i<2; i++)
10225 {
10226 if(!p_igetw(&tile,f))
10227 {
10228 return qe_invalid;
10229 }
10230
10231 if(!p_igetw(&tile2,f))
10232 {
10233 return qe_invalid;
10234 }
10235
10236 if(!p_getc(&extend,f))
10237 {
10238 return qe_invalid;
10239 }
10240
10241 holdspr[i][spr_hold1][spr_tile]=(int32_t)tile;
10242 holdspr[i][spr_hold1][spr_flip]=(int32_t)flip;
10243 holdspr[i][spr_hold1][spr_extend]=(int32_t)extend;
10244 holdspr[i][spr_hold2][spr_tile]=(int32_t)tile2;
10245 holdspr[i][spr_hold2][spr_flip]=(int32_t)flip;
10246 holdspr[i][spr_hold2][spr_extend]=(int32_t)extend;
10247 }
10248 }
10249
10250
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 77 times.
77 if(v_herosprites>2)
10251 {
10252
2/2
✓ Branch 0 taken 308 times.
✓ Branch 1 taken 77 times.
385 for(int32_t i=0; i<4; i++)
10253 {
10254
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_igetw(&tile,f))
10255 {
10256 return qe_invalid;
10257 }
10258
10259
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_getc(&flip,f))
10260 {
10261 return qe_invalid;
10262 }
10263
10264
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_getc(&extend,f))
10265 {
10266 return qe_invalid;
10267 }
10268
10269 308 jumpspr[i][spr_tile]=(int32_t)tile;
10270 308 jumpspr[i][spr_flip]=(int32_t)flip;
10271 308 jumpspr[i][spr_extend]=(int32_t)extend;
10272 308 }
10273 77 }
10274
10275
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 77 times.
77 if(v_herosprites>3)
10276 {
10277
2/2
✓ Branch 0 taken 308 times.
✓ Branch 1 taken 77 times.
385 for(int32_t i=0; i<4; i++)
10278 {
10279
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_igetw(&tile,f))
10280 {
10281 return qe_invalid;
10282 }
10283
10284
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_getc(&flip,f))
10285 {
10286 return qe_invalid;
10287 }
10288
10289
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 308 times.
308 if(!p_getc(&extend,f))
10290 {
10291 return qe_invalid;
10292 }
10293
10294 308 chargespr[i][spr_tile]=(int32_t)tile;
10295 308 chargespr[i][spr_flip]=(int32_t)flip;
10296 308 chargespr[i][spr_extend]=(int32_t)extend;
10297 308 }
10298 77 }
10299
10300
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 77 times.
77 if(v_herosprites>4)
10301 {
10302
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 if(!p_getc(&dummy_byte,f))
10303 {
10304 return qe_invalid;
10305 }
10306
10307 77 zinit.hero_swim_speed=(byte)dummy_byte;
10308 77 }
10309
10310 77 memset(frozenspr, 0, sizeof(frozenspr));
10311 77 memset(frozen_waterspr, 0, sizeof(frozen_waterspr));
10312 77 memset(onfirespr, 0, sizeof(onfirespr));
10313 77 memset(onfire_waterspr, 0, sizeof(onfire_waterspr));
10314 77 memset(diggingspr, 0, sizeof(diggingspr));
10315 77 memset(usingrodspr, 0, sizeof(usingrodspr));
10316 77 memset(usingcanespr, 0, sizeof(usingcanespr));
10317 77 memset(pushingspr, 0, sizeof(pushingspr));
10318 77 memset(liftingspr, 0, sizeof(liftingspr));
10319 77 memset(liftingwalkspr, 0, sizeof(liftingwalkspr));
10320 77 memset(stunnedspr, 0, sizeof(stunnedspr));
10321 77 memset(stunned_waterspr, 0, sizeof(stunned_waterspr));
10322 77 memset(fallingspr, 0, sizeof(fallingspr));
10323 77 memset(shockedspr, 0, sizeof(shockedspr));
10324 77 memset(shocked_waterspr, 0, sizeof(shocked_waterspr));
10325 77 memset(pullswordspr, 0, sizeof(pullswordspr));
10326 77 memset(readingspr, 0, sizeof(readingspr));
10327 77 memset(slash180spr, 0, sizeof(slash180spr));
10328 77 memset(slashZ4spr, 0, sizeof(slashZ4spr));
10329 77 memset(dashspr, 0, sizeof(dashspr));
10330 77 memset(bonkspr, 0, sizeof(bonkspr));
10331 77 memset(medallionsprs, 0, sizeof(medallionsprs));
10332 77 memset(holdspr[0][2], 0, sizeof(holdspr[0][2])); //Sword hold (Land)
10333 77 memset(holdspr[1][2], 0, sizeof(holdspr[1][2])); //Sword hold (Water)
10334
2/2
✓ Branch 0 taken 308 times.
✓ Branch 1 taken 77 times.
385 for(int32_t q = 0; q < 4; ++q)
10335 {
10336
2/2
✓ Branch 0 taken 924 times.
✓ Branch 1 taken 308 times.
1232 for(int32_t p = 0; p < 3; ++p)
10337 {
10338 924 drowningspr[q][p] = divespr[q][p];
10339 924 drowning_lavaspr[q][p] = divespr[q][p];
10340 924 }
10341 308 }
10342 77 memset(sideswimspr, 0, sizeof(sideswimspr));
10343 77 memset(sideswimslashspr, 0, sizeof(sideswimslashspr));
10344 77 memset(sideswimstabspr, 0, sizeof(sideswimstabspr));
10345 77 memset(sideswimpoundspr, 0, sizeof(sideswimpoundspr));
10346 77 memset(sideswimchargespr, 0, sizeof(sideswimchargespr));
10347 77 memset(sideswimholdspr, 0, sizeof(sideswimholdspr));
10348 77 memset(sidedrowningspr, 0, sizeof(sidedrowningspr));
10349 77 }
10350
10351
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 97 times.
97 if(FFCore.quest_format[vInitData] < 34)
10352 {
10353 97 bool fastswim = zinit.hero_swim_speed > 60;
10354 // '2/3' or '1/2'
10355 97 zinit.hero_swim_mult = fastswim ? 2 : 1;
10356 97 zinit.hero_swim_div = fastswim ? 3 : 2;
10357 97 }
10358 97 return 0;
10359 97 }
10360
10361 6460 void setSprite(int32_t* arr, int32_t tile, int32_t flip, int32_t ext)
10362 {
10363 6460 arr[spr_tile] = tile;
10364
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6460 times.
6460 arr[spr_flip] = (flip > 3 ? 0 : flip);
10365
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6460 times.
6460 arr[spr_extend] = (ext > 2 ? 0 : ext);
10366 6460 }
10367 //Used to read the player sprites as int32_t, not word.
10368 38 int32_t readherosprites3(PACKFILE *f, int32_t v_herosprites, int32_t cv_herosprites)
10369 {
10370 //these are here to bypass compiler warnings about unused arguments
10371 38 cv_herosprites=cv_herosprites;
10372
10373 38 zinit.hero_swim_speed=67; //default
10374 38 setupherotiles(zinit.heroAnimationStyle);
10375 38 setupherodefenses();
10376 38 setupherooffsets();
10377
10378 int32_t tile, tile2;
10379 byte flip, extend, dummy_byte;
10380
10381
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 38 times.
38 if(v_herosprites>=0)
10382 {
10383
10384
2/2
✓ Branch 0 taken 152 times.
✓ Branch 1 taken 38 times.
190 for(int32_t i=0; i<4; i++)
10385 {
10386
1/2
✓ Branch 0 taken 152 times.
✗ Branch 1 not taken.
152 if(!p_igetl(&tile,f))
10387 {
10388 return qe_invalid;
10389 }
10390
10391
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 152 times.
152 if(!p_getc(&flip,f))
10392 {
10393 return qe_invalid;
10394 }
10395
10396
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 152 times.
152 if(!p_getc(&extend,f))
10397 {
10398 return qe_invalid;
10399 }
10400
10401 152 setSprite(walkspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10402 152 }
10403
10404
2/2
✓ Branch 0 taken 152 times.
✓ Branch 1 taken 38 times.
190 for(int32_t i=0; i<4; i++)
10405 {
10406
1/2
✓ Branch 0 taken 152 times.
✗ Branch 1 not taken.
152 if(!p_igetl(&tile,f))
10407 {
10408 return qe_invalid;
10409 }
10410
10411
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 152 times.
152 if(!p_getc(&flip,f))
10412 {
10413 return qe_invalid;
10414 }
10415
10416
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 152 times.
152 if(!p_getc(&extend,f))
10417 {
10418 return qe_invalid;
10419 }
10420
10421 152 setSprite(stabspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10422 152 }
10423
10424
2/2
✓ Branch 0 taken 152 times.
✓ Branch 1 taken 38 times.
190 for(int32_t i=0; i<4; i++)
10425 {
10426
1/2
✓ Branch 0 taken 152 times.
✗ Branch 1 not taken.
152 if(!p_igetl(&tile,f))
10427 {
10428 return qe_invalid;
10429 }
10430
10431
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 152 times.
152 if(!p_getc(&flip,f))
10432 {
10433 return qe_invalid;
10434 }
10435
10436
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 152 times.
152 if(!p_getc(&extend,f))
10437 {
10438 return qe_invalid;
10439 }
10440
10441 152 setSprite(slashspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10442 152 }
10443
10444
2/2
✓ Branch 0 taken 152 times.
✓ Branch 1 taken 38 times.
190 for(int32_t i=0; i<4; i++)
10445 {
10446
1/2
✓ Branch 0 taken 152 times.
✗ Branch 1 not taken.
152 if(!p_igetl(&tile,f))
10447 {
10448 return qe_invalid;
10449 }
10450
10451
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 152 times.
152 if(!p_getc(&flip,f))
10452 {
10453 return qe_invalid;
10454 }
10455
10456
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 152 times.
152 if(!p_getc(&extend,f))
10457 {
10458 return qe_invalid;
10459 }
10460
10461 152 setSprite(floatspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10462 152 }
10463
10464
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 38 times.
38 if(v_herosprites>1)
10465 {
10466
2/2
✓ Branch 0 taken 152 times.
✓ Branch 1 taken 38 times.
190 for(int32_t i=0; i<4; i++)
10467 {
10468
1/2
✓ Branch 0 taken 152 times.
✗ Branch 1 not taken.
152 if(!p_igetl(&tile,f))
10469 {
10470 return qe_invalid;
10471 }
10472
10473
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 152 times.
152 if(!p_getc(&flip,f))
10474 {
10475 return qe_invalid;
10476 }
10477
10478
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 152 times.
152 if(!p_getc(&extend,f))
10479 {
10480 return qe_invalid;
10481 }
10482
10483 152 setSprite(swimspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10484 152 }
10485 38 }
10486
10487
2/2
✓ Branch 0 taken 152 times.
✓ Branch 1 taken 38 times.
190 for(int32_t i=0; i<4; i++)
10488 {
10489
1/2
✓ Branch 0 taken 152 times.
✗ Branch 1 not taken.
152 if(!p_igetl(&tile,f))
10490 {
10491 return qe_invalid;
10492 }
10493
10494
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 152 times.
152 if(!p_getc(&flip,f))
10495 {
10496 return qe_invalid;
10497 }
10498
10499
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 152 times.
152 if(!p_getc(&extend,f))
10500 {
10501 return qe_invalid;
10502 }
10503
10504 152 setSprite(divespr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10505 152 }
10506
10507
2/2
✓ Branch 0 taken 152 times.
✓ Branch 1 taken 38 times.
190 for(int32_t i=0; i<4; i++)
10508 {
10509
1/2
✓ Branch 0 taken 152 times.
✗ Branch 1 not taken.
152 if(!p_igetl(&tile,f))
10510 {
10511 return qe_invalid;
10512 }
10513
10514
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 152 times.
152 if(!p_getc(&flip,f))
10515 {
10516 return qe_invalid;
10517 }
10518
10519
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 152 times.
152 if(!p_getc(&extend,f))
10520 {
10521 return qe_invalid;
10522 }
10523
10524 152 setSprite(poundspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10525 152 }
10526
10527
1/2
✓ Branch 0 taken 38 times.
✗ Branch 1 not taken.
38 if(!p_igetl(&tile,f))
10528 {
10529 return qe_invalid;
10530 }
10531
10532 38 flip=0;
10533
10534
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 38 times.
38 if(v_herosprites>0)
10535 {
10536
1/2
✓ Branch 0 taken 38 times.
✗ Branch 1 not taken.
38 if(!p_getc(&flip,f))
10537 {
10538 return qe_invalid;
10539 }
10540 38 }
10541
10542
1/2
✓ Branch 0 taken 38 times.
✗ Branch 1 not taken.
38 if(!p_getc(&extend,f))
10543 {
10544 return qe_invalid;
10545 }
10546
10547 38 setSprite(castingspr, int32_t(tile), int32_t(flip), int32_t(extend));
10548
10549
1/2
✓ Branch 0 taken 38 times.
✗ Branch 1 not taken.
38 if(v_herosprites>0)
10550 {
10551 38 int32_t num_holdsprs = (v_herosprites > 6 ? 3 : 2);
10552
2/2
✓ Branch 0 taken 76 times.
✓ Branch 1 taken 38 times.
114 for(int32_t i=0; i<2; i++)
10553 {
10554
2/2
✓ Branch 0 taken 228 times.
✓ Branch 1 taken 76 times.
304 for(int32_t j=0; j<num_holdsprs; j++)
10555 {
10556
1/2
✓ Branch 0 taken 228 times.
✗ Branch 1 not taken.
228 if(!p_igetl(&tile,f))
10557 {
10558 return qe_invalid;
10559 }
10560
10561
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 228 times.
228 if(!p_getc(&flip,f))
10562 {
10563 return qe_invalid;
10564 }
10565
10566
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 228 times.
228 if(!p_getc(&extend,f))
10567 {
10568 return qe_invalid;
10569 }
10570
10571 228 setSprite(holdspr[i][j], int32_t(tile), int32_t(flip), int32_t(extend));
10572 228 }
10573 76 }
10574 38 }
10575 else
10576 {
10577 for(int32_t i=0; i<2; i++)
10578 {
10579 if(!p_igetl(&tile,f))
10580 {
10581 return qe_invalid;
10582 }
10583
10584 if(!p_igetl(&tile2,f))
10585 {
10586 return qe_invalid;
10587 }
10588
10589 if(!p_getc(&extend,f))
10590 {
10591 return qe_invalid;
10592 }
10593
10594 setSprite(holdspr[i][spr_hold1], int32_t(tile), int32_t(flip), int32_t(extend));
10595 setSprite(holdspr[i][spr_hold2], int32_t(tile2), int32_t(flip), int32_t(extend));
10596 }
10597 }
10598
10599
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 38 times.
38 if(v_herosprites>2)
10600 {
10601
2/2
✓ Branch 0 taken 152 times.
✓ Branch 1 taken 38 times.
190 for(int32_t i=0; i<4; i++)
10602 {
10603
1/2
✓ Branch 0 taken 152 times.
✗ Branch 1 not taken.
152 if(!p_igetl(&tile,f))
10604 {
10605 return qe_invalid;
10606 }
10607
10608
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 152 times.
152 if(!p_getc(&flip,f))
10609 {
10610 return qe_invalid;
10611 }
10612
10613
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 152 times.
152 if(!p_getc(&extend,f))
10614 {
10615 return qe_invalid;
10616 }
10617
10618 152 setSprite(jumpspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10619 152 }
10620 38 }
10621
10622
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 38 times.
38 if(v_herosprites>3)
10623 {
10624
2/2
✓ Branch 0 taken 152 times.
✓ Branch 1 taken 38 times.
190 for(int32_t i=0; i<4; i++)
10625 {
10626
1/2
✓ Branch 0 taken 152 times.
✗ Branch 1 not taken.
152 if(!p_igetl(&tile,f))
10627 {
10628 return qe_invalid;
10629 }
10630
10631
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 152 times.
152 if(!p_getc(&flip,f))
10632 {
10633 return qe_invalid;
10634 }
10635
10636
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 152 times.
152 if(!p_getc(&extend,f))
10637 {
10638 return qe_invalid;
10639 }
10640
10641 152 setSprite(chargespr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10642 152 }
10643 38 }
10644
10645
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 38 times.
38 if(v_herosprites>4)
10646 {
10647
1/2
✓ Branch 0 taken 38 times.
✗ Branch 1 not taken.
38 if(!p_getc(&dummy_byte,f))
10648 {
10649 return qe_invalid;
10650 }
10651
10652 38 zinit.hero_swim_speed=(byte)dummy_byte;
10653 38 }
10654
10655
1/2
✓ Branch 0 taken 38 times.
✗ Branch 1 not taken.
38 if(v_herosprites>6)
10656 {
10657
2/2
✓ Branch 0 taken 152 times.
✓ Branch 1 taken 38 times.
190 for(int32_t q = 0; q < 4; ++q)
10658 {
10659
1/2
✓ Branch 0 taken 152 times.
✗ Branch 1 not taken.
152 if(!p_igetl(&tile,f))
10660 return qe_invalid;
10661
10662
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 152 times.
152 if(!p_getc(&flip,f))
10663 return qe_invalid;
10664
10665
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 152 times.
152 if(!p_getc(&extend,f))
10666 return qe_invalid;
10667
10668 152 setSprite(frozenspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10669 152 }
10670
2/2
✓ Branch 0 taken 152 times.
✓ Branch 1 taken 38 times.
190 for(int32_t q = 0; q < 4; ++q)
10671 {
10672
1/2
✓ Branch 0 taken 152 times.
✗ Branch 1 not taken.
152 if(!p_igetl(&tile,f))
10673 return qe_invalid;
10674
10675
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 152 times.
152 if(!p_getc(&flip,f))
10676 return qe_invalid;
10677
10678
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 152 times.
152 if(!p_getc(&extend,f))
10679 return qe_invalid;
10680
10681 152 setSprite(frozen_waterspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10682 152 }
10683
10684
2/2
✓ Branch 0 taken 152 times.
✓ Branch 1 taken 38 times.
190 for(int32_t q = 0; q < 4; ++q)
10685 {
10686
1/2
✓ Branch 0 taken 152 times.
✗ Branch 1 not taken.
152 if(!p_igetl(&tile,f))
10687 return qe_invalid;
10688
10689
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 152 times.
152 if(!p_getc(&flip,f))
10690 return qe_invalid;
10691
10692
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 152 times.
152 if(!p_getc(&extend,f))
10693 return qe_invalid;
10694
10695 152 setSprite(onfirespr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10696 152 }
10697
2/2
✓ Branch 0 taken 152 times.
✓ Branch 1 taken 38 times.
190 for(int32_t q = 0; q < 4; ++q)
10698 {
10699
1/2
✓ Branch 0 taken 152 times.
✗ Branch 1 not taken.
152 if(!p_igetl(&tile,f))
10700 return qe_invalid;
10701
10702
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 152 times.
152 if(!p_getc(&flip,f))
10703 return qe_invalid;
10704
10705
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 152 times.
152 if(!p_getc(&extend,f))
10706 return qe_invalid;
10707
10708 152 setSprite(onfire_waterspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10709 152 }
10710
10711
2/2
✓ Branch 0 taken 152 times.
✓ Branch 1 taken 38 times.
190 for(int32_t q = 0; q < 4; ++q)
10712 {
10713
1/2
✓ Branch 0 taken 152 times.
✗ Branch 1 not taken.
152 if(!p_igetl(&tile,f))
10714 return qe_invalid;
10715
10716
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 152 times.
152 if(!p_getc(&flip,f))
10717 return qe_invalid;
10718
10719
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 152 times.
152 if(!p_getc(&extend,f))
10720 return qe_invalid;
10721
10722 152 setSprite(diggingspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10723 152 }
10724
10725
2/2
✓ Branch 0 taken 152 times.
✓ Branch 1 taken 38 times.
190 for(int32_t q = 0; q < 4; ++q)
10726 {
10727
1/2
✓ Branch 0 taken 152 times.
✗ Branch 1 not taken.
152 if(!p_igetl(&tile,f))
10728 return qe_invalid;
10729
10730
1/2
✓ Branch 0 taken 152 times.
✗ Branch 1 not taken.
152 if(!p_getc(&flip,f))
10731 return qe_invalid;
10732
10733
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 152 times.
152 if(!p_getc(&extend,f))
10734 return qe_invalid;
10735
10736 152 setSprite(usingrodspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10737 152 }
10738
10739
2/2
✓ Branch 0 taken 152 times.
✓ Branch 1 taken 38 times.
190 for(int32_t q = 0; q < 4; ++q)
10740 {
10741
1/2
✓ Branch 0 taken 152 times.
✗ Branch 1 not taken.
152 if(!p_igetl(&tile,f))
10742 return qe_invalid;
10743
10744
1/2
✓ Branch 0 taken 152 times.
✗ Branch 1 not taken.
152 if(!p_getc(&flip,f))
10745 return qe_invalid;
10746
10747
1/2
✓ Branch 0 taken 152 times.
✗ Branch 1 not taken.
152 if(!p_getc(&extend,f))
10748 return qe_invalid;
10749
10750 152 setSprite(usingcanespr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10751 152 }
10752
10753
2/2
✓ Branch 0 taken 152 times.
✓ Branch 1 taken 38 times.
190 for(int32_t q = 0; q < 4; ++q)
10754 {
10755
1/2
✓ Branch 0 taken 152 times.
✗ Branch 1 not taken.
152 if(!p_igetl(&tile,f))
10756 return qe_invalid;
10757
10758
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 152 times.
152 if(!p_getc(&flip,f))
10759 return qe_invalid;
10760
10761
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 152 times.
152 if(!p_getc(&extend,f))
10762 return qe_invalid;
10763
10764 152 setSprite(pushingspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10765 152 }
10766
10767
2/2
✓ Branch 0 taken 152 times.
✓ Branch 1 taken 38 times.
190 for(int32_t q = 0; q < 4; ++q)
10768 {
10769
1/2
✓ Branch 0 taken 152 times.
✗ Branch 1 not taken.
152 if(!p_igetl(&tile,f))
10770 return qe_invalid;
10771
10772
1/2
✓ Branch 0 taken 152 times.
✗ Branch 1 not taken.
152 if(!p_getc(&flip,f))
10773 return qe_invalid;
10774
10775
1/2
✓ Branch 0 taken 152 times.
✗ Branch 1 not taken.
152 if(!p_getc(&extend,f))
10776 return qe_invalid;
10777
10778 152 byte frames = 0;
10779
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 144 times.
152 if(v_herosprites > 15)
10780 {
10781
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(!p_getc(&frames,f))
10782 return qe_invalid;
10783 144 }
10784
10785 152 setSprite(liftingspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10786 152 liftingspr[q][spr_frames] = frames;
10787 152 }
10788
10789
2/2
✓ Branch 0 taken 152 times.
✓ Branch 1 taken 38 times.
190 for(int32_t q = 0; q < 4; ++q)
10790 {
10791
1/2
✓ Branch 0 taken 152 times.
✗ Branch 1 not taken.
152 if(!p_igetl(&tile,f))
10792 return qe_invalid;
10793
10794
1/2
✓ Branch 0 taken 152 times.
✗ Branch 1 not taken.
152 if(!p_getc(&flip,f))
10795 return qe_invalid;
10796
10797
1/2
✓ Branch 0 taken 152 times.
✗ Branch 1 not taken.
152 if(!p_getc(&extend,f))
10798 return qe_invalid;
10799
10800 152 setSprite(liftingwalkspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10801 152 }
10802
10803
2/2
✓ Branch 0 taken 152 times.
✓ Branch 1 taken 38 times.
190 for(int32_t q = 0; q < 4; ++q)
10804 {
10805
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 152 times.
152 if(!p_igetl(&tile,f))
10806 return qe_invalid;
10807
10808
1/2
✓ Branch 0 taken 152 times.
✗ Branch 1 not taken.
152 if(!p_getc(&flip,f))
10809 return qe_invalid;
10810
10811
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 152 times.
152 if(!p_getc(&extend,f))
10812 return qe_invalid;
10813
10814 152 setSprite(stunnedspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10815 152 }
10816
2/2
✓ Branch 0 taken 152 times.
✓ Branch 1 taken 38 times.
190 for(int32_t q = 0; q < 4; ++q)
10817 {
10818
1/2
✓ Branch 0 taken 152 times.
✗ Branch 1 not taken.
152 if(!p_igetl(&tile,f))
10819 return qe_invalid;
10820
10821
1/2
✓ Branch 0 taken 152 times.
✗ Branch 1 not taken.
152 if(!p_getc(&flip,f))
10822 return qe_invalid;
10823
10824
1/2
✓ Branch 0 taken 152 times.
✗ Branch 1 not taken.
152 if(!p_getc(&extend,f))
10825 return qe_invalid;
10826
10827 152 setSprite(stunned_waterspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10828 152 }
10829
10830
2/2
✓ Branch 0 taken 152 times.
✓ Branch 1 taken 38 times.
190 for(int32_t q = 0; q < 4; ++q)
10831 {
10832
1/2
✓ Branch 0 taken 152 times.
✗ Branch 1 not taken.
152 if(!p_igetl(&tile,f))
10833 return qe_invalid;
10834
10835
1/2
✓ Branch 0 taken 152 times.
✗ Branch 1 not taken.
152 if(!p_getc(&flip,f))
10836 return qe_invalid;
10837
10838
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 152 times.
152 if(!p_getc(&extend,f))
10839 return qe_invalid;
10840
10841 152 setSprite(drowningspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10842 152 }
10843
10844
2/2
✓ Branch 0 taken 152 times.
✓ Branch 1 taken 38 times.
190 for(int32_t q = 0; q < 4; ++q)
10845 {
10846
1/2
✓ Branch 0 taken 152 times.
✗ Branch 1 not taken.
152 if(!p_igetl(&tile,f))
10847 return qe_invalid;
10848
10849
1/2
✓ Branch 0 taken 152 times.
✗ Branch 1 not taken.
152 if(!p_getc(&flip,f))
10850 return qe_invalid;
10851
10852
1/2
✓ Branch 0 taken 152 times.
✗ Branch 1 not taken.
152 if(!p_getc(&extend,f))
10853 return qe_invalid;
10854
10855 152 setSprite(drowning_lavaspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10856 152 }
10857
10858
2/2
✓ Branch 0 taken 152 times.
✓ Branch 1 taken 38 times.
190 for(int32_t q = 0; q < 4; ++q)
10859 {
10860
1/2
✓ Branch 0 taken 152 times.
✗ Branch 1 not taken.
152 if(!p_igetl(&tile,f))
10861 return qe_invalid;
10862
10863
1/2
✓ Branch 0 taken 152 times.
✗ Branch 1 not taken.
152 if(!p_getc(&flip,f))
10864 return qe_invalid;
10865
10866
1/2
✓ Branch 0 taken 152 times.
✗ Branch 1 not taken.
152 if(!p_getc(&extend,f))
10867 return qe_invalid;
10868
10869 152 setSprite(fallingspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10870 152 }
10871
10872
2/2
✓ Branch 0 taken 152 times.
✓ Branch 1 taken 38 times.
190 for(int32_t q = 0; q < 4; ++q)
10873 {
10874
1/2
✓ Branch 0 taken 152 times.
✗ Branch 1 not taken.
152 if(!p_igetl(&tile,f))
10875 return qe_invalid;
10876
10877
1/2
✓ Branch 0 taken 152 times.
✗ Branch 1 not taken.
152 if(!p_getc(&flip,f))
10878 return qe_invalid;
10879
10880
1/2
✓ Branch 0 taken 152 times.
✗ Branch 1 not taken.
152 if(!p_getc(&extend,f))
10881 return qe_invalid;
10882
10883 152 setSprite(shockedspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10884 152 }
10885
2/2
✓ Branch 0 taken 152 times.
✓ Branch 1 taken 38 times.
190 for(int32_t q = 0; q < 4; ++q)
10886 {
10887
1/2
✓ Branch 0 taken 152 times.
✗ Branch 1 not taken.
152 if(!p_igetl(&tile,f))
10888 return qe_invalid;
10889
10890
1/2
✓ Branch 0 taken 152 times.
✗ Branch 1 not taken.
152 if(!p_getc(&flip,f))
10891 return qe_invalid;
10892
10893
1/2
✓ Branch 0 taken 152 times.
✗ Branch 1 not taken.
152 if(!p_getc(&extend,f))
10894 return qe_invalid;
10895
10896 152 setSprite(shocked_waterspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10897 152 }
10898
10899
2/2
✓ Branch 0 taken 152 times.
✓ Branch 1 taken 38 times.
190 for(int32_t q = 0; q < 4; ++q)
10900 {
10901
1/2
✓ Branch 0 taken 152 times.
✗ Branch 1 not taken.
152 if(!p_igetl(&tile,f))
10902 return qe_invalid;
10903
10904
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 152 times.
152 if(!p_getc(&flip,f))
10905 return qe_invalid;
10906
10907
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 152 times.
152 if(!p_getc(&extend,f))
10908 return qe_invalid;
10909
10910 152 setSprite(pullswordspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10911 152 }
10912
10913
2/2
✓ Branch 0 taken 152 times.
✓ Branch 1 taken 38 times.
190 for(int32_t q = 0; q < 4; ++q)
10914 {
10915
1/2
✓ Branch 0 taken 152 times.
✗ Branch 1 not taken.
152 if(!p_igetl(&tile,f))
10916 return qe_invalid;
10917
10918
1/2
✓ Branch 0 taken 152 times.
✗ Branch 1 not taken.
152 if(!p_getc(&flip,f))
10919 return qe_invalid;
10920
10921
1/2
✓ Branch 0 taken 152 times.
✗ Branch 1 not taken.
152 if(!p_getc(&extend,f))
10922 return qe_invalid;
10923
10924 152 setSprite(readingspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10925 152 }
10926
10927
2/2
✓ Branch 0 taken 152 times.
✓ Branch 1 taken 38 times.
190 for(int32_t q = 0; q < 4; ++q)
10928 {
10929
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 152 times.
152 if(!p_igetl(&tile,f))
10930 return qe_invalid;
10931
10932
1/2
✓ Branch 0 taken 152 times.
✗ Branch 1 not taken.
152 if(!p_getc(&flip,f))
10933 return qe_invalid;
10934
10935
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 152 times.
152 if(!p_getc(&extend,f))
10936 return qe_invalid;
10937
10938 152 setSprite(slash180spr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10939 152 }
10940
10941
2/2
✓ Branch 0 taken 152 times.
✓ Branch 1 taken 38 times.
190 for(int32_t q = 0; q < 4; ++q)
10942 {
10943
1/2
✓ Branch 0 taken 152 times.
✗ Branch 1 not taken.
152 if(!p_igetl(&tile,f))
10944 return qe_invalid;
10945
10946
1/2
✓ Branch 0 taken 152 times.
✗ Branch 1 not taken.
152 if(!p_getc(&flip,f))
10947 return qe_invalid;
10948
10949
1/2
✓ Branch 0 taken 152 times.
✗ Branch 1 not taken.
152 if(!p_getc(&extend,f))
10950 return qe_invalid;
10951
10952 152 setSprite(slashZ4spr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10953 152 }
10954
10955
2/2
✓ Branch 0 taken 152 times.
✓ Branch 1 taken 38 times.
190 for(int32_t q = 0; q < 4; ++q)
10956 {
10957
1/2
✓ Branch 0 taken 152 times.
✗ Branch 1 not taken.
152 if(!p_igetl(&tile,f))
10958 return qe_invalid;
10959
10960
1/2
✓ Branch 0 taken 152 times.
✗ Branch 1 not taken.
152 if(!p_getc(&flip,f))
10961 return qe_invalid;
10962
10963
1/2
✓ Branch 0 taken 152 times.
✗ Branch 1 not taken.
152 if(!p_getc(&extend,f))
10964 return qe_invalid;
10965
10966 152 setSprite(dashspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10967 152 }
10968
10969
2/2
✓ Branch 0 taken 152 times.
✓ Branch 1 taken 38 times.
190 for(int32_t q = 0; q < 4; ++q)
10970 {
10971
1/2
✓ Branch 0 taken 152 times.
✗ Branch 1 not taken.
152 if(!p_igetl(&tile,f))
10972 return qe_invalid;
10973
10974
1/2
✓ Branch 0 taken 152 times.
✗ Branch 1 not taken.
152 if(!p_getc(&flip,f))
10975 return qe_invalid;
10976
10977
1/2
✓ Branch 0 taken 152 times.
✗ Branch 1 not taken.
152 if(!p_getc(&extend,f))
10978 return qe_invalid;
10979
10980 152 setSprite(bonkspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10981 152 }
10982
10983
2/2
✓ Branch 0 taken 114 times.
✓ Branch 1 taken 38 times.
152 for(int32_t q = 0; q < 3; ++q) //Not directions; number of medallion sprs
10984 {
10985
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 if(!p_igetl(&tile,f))
10986 return qe_invalid;
10987
10988
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 if(!p_getc(&flip,f))
10989 return qe_invalid;
10990
10991
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 if(!p_getc(&extend,f))
10992 return qe_invalid;
10993
10994 114 setSprite(medallionsprs[q], int32_t(tile), int32_t(flip), int32_t(extend));
10995 114 }
10996 38 }
10997 else
10998 {
10999 memset(frozenspr, 0, sizeof(frozenspr));
11000 memset(frozen_waterspr, 0, sizeof(frozen_waterspr));
11001 memset(onfirespr, 0, sizeof(onfirespr));
11002 memset(onfire_waterspr, 0, sizeof(onfire_waterspr));
11003 memset(diggingspr, 0, sizeof(diggingspr));
11004 memset(usingrodspr, 0, sizeof(usingrodspr));
11005 memset(usingcanespr, 0, sizeof(usingcanespr));
11006 memset(pushingspr, 0, sizeof(pushingspr));
11007 memset(liftingspr, 0, sizeof(liftingspr));
11008 memset(liftingwalkspr, 0, sizeof(liftingwalkspr));
11009 memset(stunnedspr, 0, sizeof(stunnedspr));
11010 memset(stunned_waterspr, 0, sizeof(stunned_waterspr));
11011 memset(fallingspr, 0, sizeof(fallingspr));
11012 memset(shockedspr, 0, sizeof(shockedspr));
11013 memset(shocked_waterspr, 0, sizeof(shocked_waterspr));
11014 memset(pullswordspr, 0, sizeof(pullswordspr));
11015 memset(readingspr, 0, sizeof(readingspr));
11016 memset(slash180spr, 0, sizeof(slash180spr));
11017 memset(slashZ4spr, 0, sizeof(slashZ4spr));
11018 memset(dashspr, 0, sizeof(dashspr));
11019 memset(bonkspr, 0, sizeof(bonkspr));
11020 memset(medallionsprs, 0, sizeof(medallionsprs));
11021 memset(holdspr[0][2], 0, sizeof(holdspr[0][2])); //Sword hold (Land)
11022 memset(holdspr[1][2], 0, sizeof(holdspr[1][2])); //Sword hold (Water)
11023 for(int32_t q = 0; q < 4; ++q)
11024 {
11025 for(int32_t p = 0; p < 3; ++p)
11026 {
11027 drowningspr[q][p] = divespr[q][p];
11028 drowning_lavaspr[q][p] = divespr[q][p];
11029 }
11030 }
11031 }
11032
1/2
✓ Branch 0 taken 38 times.
✗ Branch 1 not taken.
38 if (v_herosprites > 8)
11033 {
11034
2/2
✓ Branch 0 taken 152 times.
✓ Branch 1 taken 38 times.
190 for(int32_t q = 0; q < 4; ++q)
11035 {
11036
1/2
✓ Branch 0 taken 152 times.
✗ Branch 1 not taken.
152 if(!p_igetl(&tile,f))
11037 return qe_invalid;
11038
11039
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 152 times.
152 if(!p_getc(&flip,f))
11040 return qe_invalid;
11041
11042
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 152 times.
152 if(!p_getc(&extend,f))
11043 return qe_invalid;
11044
11045 152 setSprite(sideswimspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11046 152 }
11047 38 }
11048 else
11049 {
11050 memset(sideswimspr, 0, sizeof(sideswimspr));
11051 }
11052
1/2
✓ Branch 0 taken 38 times.
✗ Branch 1 not taken.
38 if (v_herosprites > 9)
11053 {
11054
2/2
✓ Branch 0 taken 152 times.
✓ Branch 1 taken 38 times.
190 for(int32_t q = 0; q < 4; ++q)
11055 {
11056
1/2
✓ Branch 0 taken 152 times.
✗ Branch 1 not taken.
152 if(!p_igetl(&tile,f))
11057 return qe_invalid;
11058
11059
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 152 times.
152 if(!p_getc(&flip,f))
11060 return qe_invalid;
11061
11062
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 152 times.
152 if(!p_getc(&extend,f))
11063 return qe_invalid;
11064
11065 152 setSprite(sideswimslashspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11066 152 }
11067
2/2
✓ Branch 0 taken 152 times.
✓ Branch 1 taken 38 times.
190 for(int32_t q = 0; q < 4; ++q)
11068 {
11069
1/2
✓ Branch 0 taken 152 times.
✗ Branch 1 not taken.
152 if(!p_igetl(&tile,f))
11070 return qe_invalid;
11071
11072
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 152 times.
152 if(!p_getc(&flip,f))
11073 return qe_invalid;
11074
11075
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 152 times.
152 if(!p_getc(&extend,f))
11076 return qe_invalid;
11077
11078 152 setSprite(sideswimstabspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11079 152 }
11080
2/2
✓ Branch 0 taken 152 times.
✓ Branch 1 taken 38 times.
190 for(int32_t q = 0; q < 4; ++q)
11081 {
11082
1/2
✓ Branch 0 taken 152 times.
✗ Branch 1 not taken.
152 if(!p_igetl(&tile,f))
11083 return qe_invalid;
11084
11085
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 152 times.
152 if(!p_getc(&flip,f))
11086 return qe_invalid;
11087
11088
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 152 times.
152 if(!p_getc(&extend,f))
11089 return qe_invalid;
11090
11091 152 setSprite(sideswimpoundspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11092 152 }
11093
2/2
✓ Branch 0 taken 152 times.
✓ Branch 1 taken 38 times.
190 for(int32_t q = 0; q < 4; ++q)
11094 {
11095
1/2
✓ Branch 0 taken 152 times.
✗ Branch 1 not taken.
152 if(!p_igetl(&tile,f))
11096 return qe_invalid;
11097
11098
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 152 times.
152 if(!p_getc(&flip,f))
11099 return qe_invalid;
11100
11101
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 152 times.
152 if(!p_getc(&extend,f))
11102 return qe_invalid;
11103
11104 152 setSprite(sideswimchargespr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11105 152 }
11106 38 }
11107 else
11108 {
11109 memset(sideswimslashspr, 0, sizeof(sideswimslashspr));
11110 memset(sideswimstabspr, 0, sizeof(sideswimstabspr));
11111 memset(sideswimpoundspr, 0, sizeof(sideswimpoundspr));
11112 memset(sideswimchargespr, 0, sizeof(sideswimchargespr));
11113 }
11114
1/2
✓ Branch 0 taken 38 times.
✗ Branch 1 not taken.
38 if (v_herosprites > 10)
11115 {
11116
2/2
✓ Branch 0 taken 152 times.
✓ Branch 1 taken 38 times.
190 for(int32_t q = 0; q < 4; ++q)
11117 {
11118 int32_t hmr;
11119
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 152 times.
152 if(!p_igetl(&hmr,f))
11120 return qe_invalid;
11121
11122 152 hammeroffsets[q] = hmr;
11123 152 }
11124 38 }
11125 else
11126 {
11127 for(int32_t q = 0; q < 4; ++q) hammeroffsets[q] = 0;
11128 }
11129
1/2
✓ Branch 0 taken 38 times.
✗ Branch 1 not taken.
38 if (v_herosprites > 11)
11130 {
11131
2/2
✓ Branch 0 taken 114 times.
✓ Branch 1 taken 38 times.
152 for(int32_t q = 0; q < 3; ++q)
11132 {
11133
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 if(!p_igetl(&tile,f))
11134 return qe_invalid;
11135
11136
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 114 times.
114 if(!p_getc(&flip,f))
11137 return qe_invalid;
11138
11139
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 114 times.
114 if(!p_getc(&extend,f))
11140 return qe_invalid;
11141
11142 114 setSprite(sideswimholdspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11143 114 }
11144 38 }
11145 else
11146 {
11147 memset(sideswimholdspr, 0, sizeof(sideswimholdspr));
11148 }
11149
1/2
✓ Branch 0 taken 38 times.
✗ Branch 1 not taken.
38 if (v_herosprites > 12)
11150 {
11151
1/2
✓ Branch 0 taken 38 times.
✗ Branch 1 not taken.
38 if(!p_igetl(&tile,f))
11152 return qe_invalid;
11153
11154
1/2
✓ Branch 0 taken 38 times.
✗ Branch 1 not taken.
38 if(!p_getc(&flip,f))
11155 return qe_invalid;
11156
11157
1/2
✓ Branch 0 taken 38 times.
✗ Branch 1 not taken.
38 if(!p_getc(&extend,f))
11158 return qe_invalid;
11159 38 setSprite(sideswimcastingspr, int32_t(tile), int32_t(flip), int32_t(extend));
11160
11161 38 }
11162 else
11163 {
11164 memset(sideswimcastingspr, 0, sizeof(sideswimcastingspr));
11165 }
11166
1/2
✓ Branch 0 taken 38 times.
✗ Branch 1 not taken.
38 if (v_herosprites > 13)
11167 {
11168
2/2
✓ Branch 0 taken 152 times.
✓ Branch 1 taken 38 times.
190 for(int32_t q = 0; q < 4; ++q)
11169 {
11170
1/2
✓ Branch 0 taken 152 times.
✗ Branch 1 not taken.
152 if(!p_igetl(&tile,f))
11171 return qe_invalid;
11172
11173
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 152 times.
152 if(!p_getc(&flip,f))
11174 return qe_invalid;
11175
11176
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 152 times.
152 if(!p_getc(&extend,f))
11177 return qe_invalid;
11178
11179 152 setSprite(sidedrowningspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11180 152 }
11181 38 }
11182 else
11183 {
11184 memset(sidedrowningspr, 0, sizeof(sidedrowningspr));
11185 }
11186
1/2
✓ Branch 0 taken 38 times.
✗ Branch 1 not taken.
38 if (v_herosprites > 14)
11187 {
11188
2/2
✓ Branch 0 taken 152 times.
✓ Branch 1 taken 38 times.
190 for(int32_t q = 0; q < 4; ++q)
11189 {
11190
1/2
✓ Branch 0 taken 152 times.
✗ Branch 1 not taken.
152 if(!p_igetl(&tile,f))
11191 return qe_invalid;
11192
11193
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 152 times.
152 if(!p_getc(&flip,f))
11194 return qe_invalid;
11195
11196
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 152 times.
152 if(!p_getc(&extend,f))
11197 return qe_invalid;
11198
11199 152 setSprite(revslashspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11200 152 }
11201 38 }
11202 else
11203 {
11204 memset(revslashspr, 0, sizeof(revslashspr));
11205 }
11206
1/2
✓ Branch 0 taken 38 times.
✗ Branch 1 not taken.
38 if (v_herosprites > 7)
11207 {
11208 38 int32_t num_defense = wMax;
11209 38 byte def = 0;
11210
11211 //Set num_defense accordingly if changes to enum require version upgrade - Jman
11212 /*if(v_herosprites > [x])
11213 * {
11214 * num_defense = 146 //value of wMax on version 8
11215 * }
11216 */
11217
11218
2/2
✓ Branch 0 taken 5548 times.
✓ Branch 1 taken 38 times.
5586 for (int32_t q = 0; q < num_defense; q++)
11219 {
11220
1/2
✓ Branch 0 taken 5548 times.
✗ Branch 1 not taken.
5548 if (!p_getc(&def, f))
11221 return qe_invalid;
11222
11223 5548 hero_defence[q] = def;
11224 5548 }
11225 38 }
11226 else
11227 {
11228 int32_t num_defense = wMax;
11229 for (int32_t q = 0; q < num_defense; q++)
11230 {
11231 hero_defence[q] = 0;
11232 }
11233 }
11234 38 }
11235
11236
2/2
✓ Branch 0 taken 33 times.
✓ Branch 1 taken 5 times.
38 if(FFCore.quest_format[vInitData] < 34)
11237 {
11238 5 bool fastswim = zinit.hero_swim_speed > 60;
11239 // '2/3' or '1/2'
11240 5 zinit.hero_swim_mult = fastswim ? 2 : 1;
11241 5 zinit.hero_swim_div = fastswim ? 3 : 2;
11242 5 }
11243 38 return 0;
11244 38 }
11245
11246
11247 115 int32_t readherosprites(PACKFILE *f, zquestheader *Header)
11248 {
11249 //these are here to bypass compiler warnings about unused arguments
11250 115 Header=Header;
11251
11252 dword dummy;
11253 115 word s_version=0, s_cversion=0;
11254
11255 //section version info
11256
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 115 times.
115 if(!p_igetw(&s_version,f))
11257 {
11258 return qe_invalid;
11259 }
11260
11261 115 FFCore.quest_format[vHeroSprites] = s_version;
11262
11263 //al_trace("Player sprites version %d\n", s_version);
11264
1/2
✓ Branch 0 taken 115 times.
✗ Branch 1 not taken.
115 if(!p_igetw(&s_cversion,f))
11265 {
11266 return qe_invalid;
11267 }
11268
11269 //section size
11270
1/2
✓ Branch 0 taken 115 times.
✗ Branch 1 not taken.
115 if(!p_igetl(&dummy,f))
11271 {
11272 return qe_invalid;
11273 }
11274
2/2
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 77 times.
115 if ( s_version >= 6 )
11275 {
11276 //al_trace("Reading Player Sprites v6\n");
11277 38 return readherosprites3(f, s_version, dummy);
11278 }
11279 77 else return readherosprites2(f, s_version, dummy);
11280 115 }
11281
11282 86 int32_t read_old_subscreens(PACKFILE *f, word s_version)
11283 {
11284 86 subscreens_active.clear();
11285 86 subscreens_passive.clear();
11286 86 subscreens_overlay.clear();
11287
2/2
✓ Branch 0 taken 11008 times.
✓ Branch 1 taken 86 times.
11094 for(int32_t i=0; i<MAXCUSTOMSUBSCREENS; i++)
11288 {
11289 subscreen_group g;
11290 11008 memset(&g,0,sizeof(subscreen_group));
11291 11008 int32_t ret = read_one_old_subscreen(f, &g, s_version);
11292
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11008 times.
11008 if(ret!=0)
11293 return ret;
11294
2/2
✓ Branch 0 taken 395 times.
✓ Branch 1 taken 10613 times.
11008 if(g.objects[0].type == ssoNULL) continue;
11295
2/2
✓ Branch 0 taken 188 times.
✓ Branch 1 taken 207 times.
395 auto& vec = g.ss_type == sstPASSIVE ? subscreens_passive : subscreens_active;
11296 395 ZCSubscreen& sub = vec.emplace_back();
11297 395 sub.load_old(g);
11298 395 }
11299
11300 86 return 0;
11301 86 }
11302
11303 11008 int32_t read_one_old_subscreen(PACKFILE *f, subscreen_group* g, word s_version)
11304 {
11305 11008 int32_t numsub=0;
11306 11008 byte temp_ss=0;
11307 subscreen_object temp_sub_stack;
11308 11008 subscreen_object *temp_sub = &temp_sub_stack;
11309
11310 char tempname[64];
11311
11312 // FWIW I never saw anything bigger than 20.
11313 #define MAX_DP1_LEN 1024
11314 char tempdp1[MAX_DP1_LEN];
11315
11316
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11008 times.
11008 if(!pfread(tempname,64,f))
11317 {
11318 return qe_invalid;
11319 }
11320
11321
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11008 times.
11008 if(s_version > 1)
11322 {
11323
1/2
✓ Branch 0 taken 11008 times.
✗ Branch 1 not taken.
11008 if(!p_getc(&temp_ss,f))
11324 {
11325 return qe_invalid;
11326 }
11327 11008 }
11328
11329
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11008 times.
11008 if(s_version < 4)
11330 {
11331 uint8_t tmp=0;
11332
11333 if(!p_getc(&tmp,f))
11334 {
11335 return qe_invalid;
11336 }
11337
11338 numsub = (int32_t)tmp;
11339 }
11340 else
11341 {
11342 word tmp;
11343
11344
1/2
✓ Branch 0 taken 11008 times.
✗ Branch 1 not taken.
11008 if(!p_igetw(&tmp, f))
11345 {
11346 return qe_invalid;
11347 }
11348
11349 11008 numsub = (int32_t)tmp;
11350 }
11351
11352 int32_t j;
11353
11354
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 24251 times.
✓ Branch 2 taken 13243 times.
✓ Branch 3 taken 11008 times.
24251 for(j=0; (j<MAXSUBSCREENITEMS&&j<numsub); j++)
11355 {
11356 13243 memset(temp_sub,0,sizeof(subscreen_object));
11357
11358
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13243 times.
13243 switch(g->objects[j].type)
11359 {
11360 case ssoTEXT:
11361 case ssoTEXTBOX:
11362 case ssoCURRENTITEMTEXT:
11363 case ssoCURRENTITEMCLASSTEXT:
11364 if(g->objects[j].dp1 != NULL) delete [](char *)g->objects[j].dp1;
11365
11366 //fall through
11367 default:
11368 13243 memset(&g->objects[j],0,sizeof(subscreen_object));
11369 13243 break;
11370 }
11371
11372
1/2
✓ Branch 0 taken 13243 times.
✗ Branch 1 not taken.
13243 if(!p_getc(&(temp_sub->type),f))
11373 return qe_invalid;
11374
11375
1/2
✓ Branch 0 taken 13243 times.
✗ Branch 1 not taken.
13243 if(!p_getc(&(temp_sub->pos),f))
11376 return qe_invalid;
11377
11378
1/2
✓ Branch 0 taken 13243 times.
✗ Branch 1 not taken.
13243 if(s_version < 5)
11379 {
11380 switch(temp_sub->pos)
11381 {
11382 case 0:
11383 temp_sub->pos = sspUP | sspDOWN | sspSCROLLING;
11384 break;
11385
11386 case 1:
11387 temp_sub->pos = sspUP;
11388 break;
11389
11390 case 2:
11391 temp_sub->pos = sspDOWN;
11392 break;
11393
11394 default:
11395 temp_sub->pos = 0;
11396 }
11397 }
11398
11399
1/2
✓ Branch 0 taken 13243 times.
✗ Branch 1 not taken.
13243 if(!p_igetw(&(temp_sub->x),f))
11400 return qe_invalid;
11401
11402
1/2
✓ Branch 0 taken 13243 times.
✗ Branch 1 not taken.
13243 if(!p_igetw(&(temp_sub->y),f))
11403 return qe_invalid;
11404
11405
1/2
✓ Branch 0 taken 13243 times.
✗ Branch 1 not taken.
13243 if(!p_igetw(&(temp_sub->w),f))
11406 return qe_invalid;
11407
11408
1/2
✓ Branch 0 taken 13243 times.
✗ Branch 1 not taken.
13243 if(!p_igetw(&(temp_sub->h),f))
11409 return qe_invalid;
11410
11411
1/2
✓ Branch 0 taken 13243 times.
✗ Branch 1 not taken.
13243 if(!p_getc(&(temp_sub->colortype1),f))
11412 return qe_invalid;
11413
11414
1/2
✓ Branch 0 taken 13243 times.
✗ Branch 1 not taken.
13243 if(!p_igetw(&(temp_sub->color1),f))
11415 return qe_invalid;
11416
11417
1/2
✓ Branch 0 taken 13243 times.
✗ Branch 1 not taken.
13243 if(!p_getc(&(temp_sub->colortype2),f))
11418 return qe_invalid;
11419
11420
1/2
✓ Branch 0 taken 13243 times.
✗ Branch 1 not taken.
13243 if(!p_igetw(&(temp_sub->color2),f))
11421 return qe_invalid;
11422
11423
1/2
✓ Branch 0 taken 13243 times.
✗ Branch 1 not taken.
13243 if(!p_getc(&(temp_sub->colortype3),f))
11424 return qe_invalid;
11425
11426
1/2
✓ Branch 0 taken 13243 times.
✗ Branch 1 not taken.
13243 if(!p_igetw(&(temp_sub->color3),f))
11427 return qe_invalid;
11428
11429
1/2
✓ Branch 0 taken 13243 times.
✗ Branch 1 not taken.
13243 if(!p_igetd(&(temp_sub->d1),f))
11430 return qe_invalid;
11431
11432
1/2
✓ Branch 0 taken 13243 times.
✗ Branch 1 not taken.
13243 if(!p_igetd(&(temp_sub->d2),f))
11433 return qe_invalid;
11434
11435
1/2
✓ Branch 0 taken 13243 times.
✗ Branch 1 not taken.
13243 if(!p_igetd(&(temp_sub->d3),f))
11436 return qe_invalid;
11437
11438
1/2
✓ Branch 0 taken 13243 times.
✗ Branch 1 not taken.
13243 if(!p_igetd(&(temp_sub->d4),f))
11439 return qe_invalid;
11440
11441
1/2
✓ Branch 0 taken 13243 times.
✗ Branch 1 not taken.
13243 if(!p_igetd(&(temp_sub->d5),f))
11442 return qe_invalid;
11443
11444
1/2
✓ Branch 0 taken 13243 times.
✗ Branch 1 not taken.
13243 if(!p_igetd(&(temp_sub->d6),f))
11445 return qe_invalid;
11446
11447
1/2
✓ Branch 0 taken 13243 times.
✗ Branch 1 not taken.
13243 if(!p_igetd(&(temp_sub->d7),f))
11448 return qe_invalid;
11449
11450
1/2
✓ Branch 0 taken 13243 times.
✗ Branch 1 not taken.
13243 if(!p_igetd(&(temp_sub->d8),f))
11451 return qe_invalid;
11452
11453
1/2
✓ Branch 0 taken 13243 times.
✗ Branch 1 not taken.
13243 if(!p_igetd(&(temp_sub->d9),f))
11454 return qe_invalid;
11455
11456
1/2
✓ Branch 0 taken 13243 times.
✗ Branch 1 not taken.
13243 if(!p_igetd(&(temp_sub->d10),f))
11457 return qe_invalid;
11458
11459
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13243 times.
13243 if(s_version < 2)
11460 {
11461 if(!p_igetl(&(temp_sub->speed),f))
11462 return qe_invalid;
11463
11464 if(!p_igetl(&(temp_sub->delay),f))
11465 return qe_invalid;
11466
11467 if(!p_igetl(&(temp_sub->frame),f))
11468 return qe_invalid;
11469 }
11470 else
11471 {
11472
1/2
✓ Branch 0 taken 13243 times.
✗ Branch 1 not taken.
13243 if(!p_getc(&(temp_sub->speed),f))
11473 return qe_invalid;
11474
11475
1/2
✓ Branch 0 taken 13243 times.
✗ Branch 1 not taken.
13243 if(!p_getc(&(temp_sub->delay),f))
11476 return qe_invalid;
11477
11478
1/2
✓ Branch 0 taken 13243 times.
✗ Branch 1 not taken.
13243 if(!p_igetw(&(temp_sub->frame),f))
11479 return qe_invalid;
11480 }
11481
11482 13243 int32_t temp_size=0;
11483
11484 // bool deletets = false;
11485
4/4
✓ Branch 0 taken 5853 times.
✓ Branch 1 taken 1329 times.
✓ Branch 2 taken 5910 times.
✓ Branch 3 taken 151 times.
13243 switch(temp_sub->type)
11486 {
11487 case ssoTEXT:
11488 case ssoTEXTBOX:
11489 case ssoCURRENTITEMTEXT:
11490 case ssoCURRENTITEMCLASSTEXT:
11491 {
11492 word temptempsize;
11493
11494
1/2
✓ Branch 0 taken 1329 times.
✗ Branch 1 not taken.
1329 if(!p_igetw(&temptempsize,f))
11495 {
11496 return qe_invalid;
11497 }
11498
11499 //temptempsize = temp1 + (temp2 << 8);
11500 1329 temp_size = (int32_t)temptempsize;
11501 1329 uint32_t char_length = temp_size+2;
11502
1/2
✓ Branch 0 taken 1329 times.
✗ Branch 1 not taken.
1329 if (char_length > MAX_DP1_LEN)
11503 {
11504 return qe_invalid;
11505 }
11506 1329 tempdp1[char_length - 1] = '\0';
11507
11508
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1329 times.
1329 if(temp_size)
11509
1/2
✓ Branch 0 taken 1329 times.
✗ Branch 1 not taken.
1329 if(!pfread(tempdp1,temp_size+1,f))
11510 return qe_invalid;
11511 1329 break;
11512 }
11513
11514 case ssoLIFEMETER:
11515
1/2
✓ Branch 0 taken 151 times.
✗ Branch 1 not taken.
151 if(get_bit(deprecated_rules, 12) != 0) // qr_24HC
11516 temp_sub->d3 = 1;
11517
11518
1/2
✓ Branch 0 taken 151 times.
✗ Branch 1 not taken.
151 if(!p_getc(&(temp_sub->dp1),f))
11519 return qe_invalid;
11520
11521 151 break;
11522
11523
11524 case ssoCURRENTITEM:
11525
11526
1/2
✓ Branch 0 taken 5853 times.
✗ Branch 1 not taken.
5853 if(s_version < 6)
11527 {
11528 switch(temp_sub->d1)
11529 {
11530 case ssiBOMB:
11531 temp_sub->d1 = itype_bomb;
11532 break;
11533
11534 case ssiSWORD:
11535 temp_sub->d1 = itype_sword;
11536 break;
11537
11538 case ssiSHIELD:
11539 temp_sub->d1 = itype_shield;
11540 break;
11541
11542 case ssiCANDLE:
11543 temp_sub->d1 = itype_candle;
11544 break;
11545
11546 case ssiLETTER:
11547 temp_sub->d1 = itype_letter;
11548 break;
11549
11550 case ssiPOTION:
11551 temp_sub->d1 = itype_potion;
11552 break;
11553
11554 case ssiLETTERPOTION:
11555 temp_sub->d1 = itype_letterpotion;
11556 break;
11557
11558 case ssiBOW:
11559 temp_sub->d1 = itype_bow;
11560 break;
11561
11562 case ssiARROW:
11563 temp_sub->d1 = itype_arrow;
11564 break;
11565
11566 case ssiBOWANDARROW:
11567 temp_sub->d1 = itype_bowandarrow;
11568 break;
11569
11570 case ssiBAIT:
11571 temp_sub->d1 = itype_bait;
11572 break;
11573
11574 case ssiRING:
11575 temp_sub->d1 = itype_ring;
11576 break;
11577
11578 case ssiBRACELET:
11579 temp_sub->d1 = itype_bracelet;
11580 break;
11581
11582 case ssiMAP:
11583 temp_sub->d1 = itype_map;
11584 break;
11585
11586 case ssiCOMPASS:
11587 temp_sub->d1 = itype_compass;
11588 break;
11589
11590 case ssiBOSSKEY:
11591 temp_sub->d1 = itype_bosskey;
11592 break;
11593
11594 case ssiMAGICKEY:
11595 temp_sub->d1 = itype_magickey;
11596 break;
11597
11598 case ssiBRANG:
11599 temp_sub->d1 = itype_brang;
11600 break;
11601
11602 case ssiWAND:
11603 temp_sub->d1 = itype_wand;
11604 break;
11605
11606 case ssiRAFT:
11607 temp_sub->d1 = itype_raft;
11608 break;
11609
11610 case ssiLADDER:
11611 temp_sub->d1 = itype_ladder;
11612 break;
11613
11614 case ssiWHISTLE:
11615 temp_sub->d1 = itype_whistle;
11616 break;
11617
11618 case ssiBOOK:
11619 temp_sub->d1 = itype_book;
11620 break;
11621
11622 case ssiWALLET:
11623 temp_sub->d1 = itype_wallet;
11624 break;
11625
11626 case ssiSBOMB:
11627 temp_sub->d1 = itype_sbomb;
11628 break;
11629
11630 case ssiHCPIECE:
11631 temp_sub->d1 = itype_heartpiece;
11632 break;
11633
11634 case ssiAMULET:
11635 temp_sub->d1 = itype_amulet;
11636 break;
11637
11638 case ssiFLIPPERS:
11639 temp_sub->d1 = itype_flippers;
11640 break;
11641
11642 case ssiHOOKSHOT:
11643 temp_sub->d1 = itype_hookshot;
11644 break;
11645
11646 case ssiLENS:
11647 temp_sub->d1 = itype_lens;
11648 break;
11649
11650 case ssiHAMMER:
11651 temp_sub->d1 = itype_hammer;
11652 break;
11653
11654 case ssiBOOTS:
11655 temp_sub->d1 = itype_boots;
11656 break;
11657
11658 case ssiDIVINEFIRE:
11659 temp_sub->d1 = itype_divinefire;
11660 break;
11661
11662 case ssiDIVINEESCAPE:
11663 temp_sub->d1 = itype_divineescape;
11664 break;
11665
11666 case ssiDIVINEPROTECTION:
11667 temp_sub->d1 = itype_divineprotection;
11668 break;
11669
11670 case ssiQUIVER:
11671 temp_sub->d1 = itype_quiver;
11672 break;
11673
11674 case ssiBOMBBAG:
11675 temp_sub->d1 = itype_bombbag;
11676 break;
11677
11678 case ssiCBYRNA:
11679 temp_sub->d1 = itype_cbyrna;
11680 break;
11681
11682 case ssiROCS:
11683 temp_sub->d1 = itype_rocs;
11684 break;
11685
11686 case ssiHOVERBOOTS:
11687 temp_sub->d1 = itype_hoverboots;
11688 break;
11689
11690 case ssiSPINSCROLL:
11691 temp_sub->d1 = itype_spinscroll;
11692 break;
11693
11694 case ssiCROSSSCROLL:
11695 temp_sub->d1 = itype_crossscroll;
11696 break;
11697
11698 case ssiQUAKESCROLL:
11699 temp_sub->d1 = itype_quakescroll;
11700 break;
11701
11702 case ssiWHISPRING:
11703 temp_sub->d1 = itype_whispring;
11704 break;
11705
11706 case ssiCHARGERING:
11707 temp_sub->d1 = itype_chargering;
11708 break;
11709
11710 case ssiPERILSCROLL:
11711 temp_sub->d1 = itype_perilscroll;
11712 break;
11713
11714 case ssiWEALTHMEDAL:
11715 temp_sub->d1 = itype_wealthmedal;
11716 break;
11717
11718 case ssiHEARTRING:
11719 temp_sub->d1 = itype_heartring;
11720 break;
11721
11722 case ssiMAGICRING:
11723 temp_sub->d1 = itype_magicring;
11724 break;
11725
11726 case ssiSPINSCROLL2:
11727 temp_sub->d1 = itype_spinscroll2;
11728 break;
11729
11730 case ssiQUAKESCROLL2:
11731 temp_sub->d1 = itype_quakescroll2;
11732 break;
11733
11734 case ssiAGONY:
11735 temp_sub->d1 = itype_agony;
11736 break;
11737
11738 case ssiSTOMPBOOTS:
11739 temp_sub->d1 = itype_stompboots;
11740 break;
11741
11742 case ssiWHIMSICALRING:
11743 temp_sub->d1 = itype_whimsicalring;
11744 break;
11745
11746 case ssiPERILRING:
11747 temp_sub->d1 = itype_perilring;
11748 break;
11749
11750 default:
11751 temp_sub->d1 += itype_custom1 - ssiMAX;
11752 }
11753 }
11754
11755 //fall-through
11756 default:
11757
1/2
✓ Branch 0 taken 11763 times.
✗ Branch 1 not taken.
11763 if(!p_getc(&(temp_sub->dp1),f))
11758 return qe_invalid;
11759
11760 11763 break;
11761 }
11762
11763
2/2
✓ Branch 0 taken 4559 times.
✓ Branch 1 taken 8684 times.
13243 if(s_version < 7)
11764 {
11765
3/3
✓ Branch 0 taken 8025 times.
✓ Branch 1 taken 227 times.
✓ Branch 2 taken 432 times.
8684 switch(temp_sub->type)
11766 {
11767 case ssoMAGICGAUGE:
11768 {
11769
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 192 times.
227 if(!temp_sub->d9)
11770 192 temp_sub->d9 = -1; //-1 now represents 'always'
11771 227 break;
11772 }
11773 case ssoLIFEGAUGE:
11774 432 temp_sub->d9 = 0; //Unused, doesn't do anything? Clear it...
11775 432 break;
11776 }
11777 8684 }
11778
11779
3/3
✓ Branch 0 taken 1329 times.
✓ Branch 1 taken 11457 times.
✓ Branch 2 taken 457 times.
13243 switch(temp_sub->type)
11780 {
11781 case ssoTEXT:
11782 case ssoTEXTBOX:
11783 case ssoCURRENTITEMTEXT:
11784 case ssoCURRENTITEMCLASSTEXT:
11785
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1329 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1329 if(g->objects[j].dp1 != NULL) delete[](char *)g->objects[j].dp1;
11786
11787 1329 memcpy(&g->objects[j],temp_sub,sizeof(subscreen_object));
11788 1329 g->objects[j].dp1 = new char[temp_size+2];
11789 1329 strcpy((char*)g->objects[j].dp1,tempdp1);
11790 1329 break;
11791
11792 case ssoCOUNTER:
11793
1/2
✓ Branch 0 taken 457 times.
✗ Branch 1 not taken.
457 if(s_version<3)
11794 {
11795 temp_sub->d6=(temp_sub->d6?1:0)+(temp_sub->d8?2:0);
11796 temp_sub->d8=0;
11797 }
11798
11799 default:
11800 11914 memcpy(&g->objects[j],temp_sub,sizeof(subscreen_object));
11801 11914 break;
11802 }
11803
11804 13243 g->name[0] = '\0';
11805 13243 strncat(g->name, tempname, 64 - 1);
11806 13243 g->ss_type = temp_ss;
11807 13243 }
11808
11809
2/2
✓ Branch 0 taken 2804805 times.
✓ Branch 1 taken 11008 times.
2815813 for(j=numsub; j<MAXSUBSCREENITEMS; j++)
11810 {
11811 //clear all unused object in this subscreen -DD
11812
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2804805 times.
2804805 switch(g->objects[j].type)
11813 {
11814 case ssoTEXT:
11815 case ssoTEXTBOX:
11816 case ssoCURRENTITEMTEXT:
11817 case ssoCURRENTITEMCLASSTEXT:
11818 if(g->objects[j].dp1 != NULL) delete [](char *)g->objects[j].dp1;
11819
11820 //fall through
11821 default:
11822 2804805 memset(&g->objects[j],0,sizeof(subscreen_object));
11823 2804805 break;
11824 }
11825 2804805 }
11826
11827 11008 return 0;
11828 11008 }
11829
11830 115 int32_t readsubscreens(PACKFILE *f)
11831 {
11832 word s_version, s_cversion;
11833 dword dummy;
11834
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 115 times.
115 if(!p_igetw(&s_version,f))
11835 return qe_invalid;
11836 115 FFCore.quest_format[vSubscreen] = s_version;
11837
1/2
✓ Branch 0 taken 115 times.
✗ Branch 1 not taken.
115 if(!p_igetw(&s_cversion,f))
11838 return qe_invalid;
11839
1/2
✓ Branch 0 taken 115 times.
✗ Branch 1 not taken.
115 if(!p_igetl(&dummy,f)) //section size
11840 return qe_invalid;
11841
11842
2/2
✓ Branch 0 taken 86 times.
✓ Branch 1 taken 29 times.
115 if(s_version < 8)
11843 86 return read_old_subscreens(f,s_version);
11844
11845 29 subscreens_active.clear();
11846 29 subscreens_passive.clear();
11847 29 subscreens_overlay.clear();
11848
11849 byte sz;
11850
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29 if(!p_getc(&sz,f))
11851 return qe_invalid;
11852
2/2
✓ Branch 0 taken 92 times.
✓ Branch 1 taken 29 times.
121 for(byte q = 0; q < sz; ++q)
11853 {
11854 92 ZCSubscreen& tmp = subscreens_active.emplace_back();
11855
1/2
✓ Branch 0 taken 92 times.
✗ Branch 1 not taken.
92 if (auto ret = tmp.read(f, s_version))
11856 return ret;
11857 92 }
11858
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29 if(!p_getc(&sz,f))
11859 return qe_invalid;
11860
2/2
✓ Branch 0 taken 116 times.
✓ Branch 1 taken 29 times.
145 for(byte q = 0; q < sz; ++q)
11861 {
11862 116 ZCSubscreen& tmp = subscreens_passive.emplace_back();
11863
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 if (auto ret = tmp.read(f, s_version))
11864 return ret;
11865 116 }
11866
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29 if(!p_getc(&sz,f))
11867 return qe_invalid;
11868
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 29 times.
45 for(byte q = 0; q < sz; ++q)
11869 {
11870 16 ZCSubscreen& tmp = subscreens_overlay.emplace_back();
11871
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if (auto ret = tmp.read(f, s_version))
11872 return ret;
11873 16 }
11874 29 return 0;
11875 115 }
11876
11877 void reset_subscreen(subscreen_group *tempss)
11878 {
11879 for(int32_t i=0; i<MAXSUBSCREENITEMS; ++i)
11880 {
11881 switch(tempss->objects[i].type)
11882 {
11883 case ssoTEXT:
11884 case ssoTEXTBOX:
11885 case ssoCURRENTITEMTEXT:
11886 case ssoCURRENTITEMCLASSTEXT:
11887 if(tempss->objects[i].dp1 != NULL) delete [](char *)tempss->objects[i].dp1;
11888
11889 //fall through
11890 default:
11891 memset(&tempss->objects[i],0,sizeof(subscreen_object));
11892 break;
11893 }
11894 }
11895 }
11896
11897 31 void reset_subscreens()
11898 {
11899 31 subscreens_active.clear();
11900 31 subscreens_passive.clear();
11901 31 subscreens_overlay.clear();
11902 31 }
11903
11904 31 int32_t setupsubscreens()
11905 {
11906 31 reset_subscreens();
11907 //return 0;
11908
2/2
✓ Branch 0 taken 31 times.
✓ Branch 1 taken 62 times.
93 for(int q = 0; q < 2; ++q)
11909 {
11910 62 subscreens_active.emplace_back();
11911 62 subscreens_passive.emplace_back();
11912 62 }
11913 31 int32_t tempsubscreen=subscr_mode;
11914
11915
1/2
✓ Branch 0 taken 31 times.
✗ Branch 1 not taken.
31 if(tempsubscreen>=ssdtMAX)
11916 tempsubscreen=0;
11917
11918
1/3
✗ Branch 0 not taken.
✓ Branch 1 taken 31 times.
✗ Branch 2 not taken.
31 switch(tempsubscreen)
11919 {
11920 case ssdtOLD:
11921 case ssdtNEWSUBSCR:
11922 case ssdtREV2:
11923 case ssdtBSZELDA:
11924 case ssdtBSZELDAMODIFIED:
11925 case ssdtBSZELDAENHANCED:
11926 case ssdtBSZELDACOMPLETE:
11927 {
11928 31 subscreens_active[0].load_old(default_subscreen_active[tempsubscreen][0]);
11929 31 subscreens_active[0].sub_type=sstACTIVE;
11930 31 subscreens_active[0].name = "Active Subscreen (Triforce)";
11931 31 subscreens_active[1].load_old(default_subscreen_active[tempsubscreen][1]);
11932 31 subscreens_active[1].sub_type=sstACTIVE;
11933 31 subscreens_active[1].name = "Active Subscreen (Dungeon Map)";
11934 31 subscreens_passive[0].load_old(default_subscreen_passive[tempsubscreen][0]);
11935 31 subscreens_passive[0].sub_type=sstPASSIVE;
11936 31 subscreens_passive[0].name = "Passive Subscreen (Magic)";
11937 31 subscreens_passive[1].load_old(default_subscreen_passive[tempsubscreen][1]);
11938 31 subscreens_passive[1].sub_type=sstPASSIVE;
11939 31 subscreens_passive[1].name = "Passive Subscreen (No Magic)";
11940 31 break;
11941 }
11942
11943 case ssdtZ3:
11944 {
11945 subscreens_active[0].load_old(z3_active_a);
11946 subscreens_active[0].sub_type=sstACTIVE;
11947 subscreens_active[1].load_old(z3_active_ab);
11948 subscreens_active[1].sub_type=sstACTIVE;
11949 subscreens_passive[0].load_old(z3_passive_a);
11950 subscreens_passive[0].sub_type=sstPASSIVE;
11951 subscreens_passive[1].load_old(z3_passive_ab);
11952 subscreens_passive[1].sub_type=sstPASSIVE;
11953 break;
11954 }
11955 }
11956 31 subscr_mode = ssdtMAX;
11957 31 return 0;
11958 }
11959
11960 extern script_data *ffscripts[NUMSCRIPTFFC];
11961 extern script_data *itemscripts[NUMSCRIPTITEM];
11962 extern script_data *guyscripts[NUMSCRIPTGUYS];
11963 extern script_data *lwpnscripts[NUMSCRIPTWEAPONS];
11964 extern script_data *ewpnscripts[NUMSCRIPTWEAPONS];
11965 extern script_data *globalscripts[NUMSCRIPTGLOBAL];
11966 extern script_data *genericscripts[NUMSCRIPTSGENERIC];
11967 extern script_data *playerscripts[NUMSCRIPTPLAYER];
11968 extern script_data *screenscripts[NUMSCRIPTSCREEN];
11969 extern script_data *dmapscripts[NUMSCRIPTSDMAP];
11970 extern script_data *itemspritescripts[NUMSCRIPTSITEMSPRITE];
11971 extern script_data *comboscripts[NUMSCRIPTSCOMBODATA];
11972 extern script_data *subscreenscripts[NUMSCRIPTSSUBSCREEN];
11973
11974
11975
11976 101 int32_t readffscript(PACKFILE *f, zquestheader *Header)
11977 {
11978 int32_t dummy;
11979 101 word s_version=0, s_cversion=0, zmeta_version=0;
11980 101 byte numscripts=0;
11981 101 numscripts=numscripts; //to avoid unused variables warnings
11982 int32_t ret;
11983
11984 //section version info
11985
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 101 times.
101 if(!p_igetw(&s_version,f))
11986 {
11987 return qe_invalid;
11988 }
11989
11990 101 FFCore.quest_format[vFFScript] = s_version;
11991
11992
1/2
✓ Branch 0 taken 101 times.
✗ Branch 1 not taken.
101 if(!p_igetw(&s_cversion,f))
11993 {
11994 return qe_invalid;
11995 }
11996
11997
2/2
✓ Branch 0 taken 63 times.
✓ Branch 1 taken 38 times.
101 if(s_version >= 18)
11998 {
11999
1/2
✓ Branch 0 taken 38 times.
✗ Branch 1 not taken.
38 if(!p_igetw(&zmeta_version,f))
12000 {
12001 return qe_invalid;
12002 }
12003 38 }
12004
12005 //al_trace("Scripts version %d\n", s_version);
12006 //section size
12007
1/2
✓ Branch 0 taken 101 times.
✗ Branch 1 not taken.
101 if(!p_igetl(&dummy,f))
12008 {
12009 return qe_invalid;
12010 }
12011
12012 //ZScriptVersion::setVersion(s_version); ~this ideally, but there's no ZC/ZQuest defines...
12013 101 setZScriptVersion(s_version); //Lumped in zelda.cpp and in zquest.cpp as zquest can't link ZScriptVersion
12014 //miscQdata *the_misc;
12015
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 77 times.
101 if ( FFCore.quest_format[vLastCompile] < 13 ) FFCore.quest_format[vLastCompile] = s_version;
12016 101 al_trace("Loaded scripts last compiled in ZScript version: %d\n", (FFCore.quest_format[vLastCompile]));
12017
12018 //finally... section data
12019
2/2
✓ Branch 0 taken 58880 times.
✓ Branch 1 taken 59 times.
58981 for(int32_t i = 0; i < ((s_version < 2) ? NUMSCRIPTFFCOLD : NUMSCRIPTFFC); i++)
12020 {
12021 58880 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &ffscripts[i], zmeta_version);
12022
12023
1/2
✓ Branch 0 taken 58880 times.
✗ Branch 1 not taken.
58880 if (ret)
12024 {
12025 return qe_invalid;
12026 }
12027 58880 }
12028
12029 /* HIGHLY UNORTHODOX UPDATING THING, by Deedee
12030 * This fixes changes to sprite jump values introduced in early 2.55 alphas.
12031 * Zoria didn't bump up the versions as liberally as he should have, but thankfully
12032 * there was a version bump a week before a change that broke stuff.
12033 */
12034
7/8
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 21 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 38 times.
✓ Branch 4 taken 38 times.
✓ Branch 5 taken 38 times.
✓ Branch 6 taken 38 times.
✓ Branch 7 taken 38 times.
59 if(((Header->zelda_version < 0x253)||((Header->zelda_version == 0x253)&&(Header->build<33))||((Header->zelda_version > 0x253) && s_version < 12)))
12035 {
12036 97 set_qr(qr_SPRITE_JUMP_IS_TRUNCATED,1);
12037 97 }
12038
2/2
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 77 times.
115 if(s_version < 19)
12039 {
12040 77 set_qr(qr_FLUCTUATING_ENEMY_JUMP,1);
12041 77 }
12042
12043
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 115 times.
115 if(s_version > 1)
12044 {
12045
2/2
✓ Branch 0 taken 29440 times.
✓ Branch 1 taken 115 times.
29555 for(int32_t i = 0; i < NUMSCRIPTITEM; i++)
12046 {
12047 29440 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &itemscripts[i], zmeta_version);
12048
12049
1/2
✓ Branch 0 taken 29440 times.
✗ Branch 1 not taken.
29440 if (ret)
12050 {
12051 return qe_invalid;
12052 }
12053 29440 }
12054
12055
2/2
✓ Branch 0 taken 29440 times.
✓ Branch 1 taken 115 times.
29555 for(int32_t i = 0; i < NUMSCRIPTGUYS; i++)
12056 {
12057 29440 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &guyscripts[i], zmeta_version);
12058
12059
1/2
✓ Branch 0 taken 29440 times.
✗ Branch 1 not taken.
29440 if (ret)
12060 {
12061 return qe_invalid;
12062 }
12063 29440 }
12064
12065
1/2
✓ Branch 0 taken 115 times.
✗ Branch 1 not taken.
115 script_data *fake = new script_data(ScriptType::None, 0);
12066
2/2
✓ Branch 0 taken 29440 times.
✓ Branch 1 taken 115 times.
29555 for(int32_t i = 0; i < NUMSCRIPTWEAPONS; i++)
12067 {
12068 29440 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &fake, zmeta_version);
12069
12070
1/2
✓ Branch 0 taken 29440 times.
✗ Branch 1 not taken.
29440 if (ret)
12071 {
12072 return qe_invalid;
12073 }
12074 29440 }
12075
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 115 times.
115 delete fake;
12076
12077
2/2
✓ Branch 0 taken 29440 times.
✓ Branch 1 taken 115 times.
29555 for(int32_t i = 0; i < NUMSCRIPTSCREEN; i++)
12078 {
12079 29440 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &screenscripts[i], zmeta_version);
12080
12081
1/2
✓ Branch 0 taken 29440 times.
✗ Branch 1 not taken.
29440 if (ret)
12082 {
12083 return qe_invalid;
12084 }
12085 29440 }
12086
12087
2/2
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 77 times.
115 if(s_version > 16)
12088 {
12089
2/2
✓ Branch 0 taken 304 times.
✓ Branch 1 taken 38 times.
342 for(int32_t i = 0; i < NUMSCRIPTGLOBAL; ++i)
12090 {
12091 304 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &globalscripts[i], zmeta_version);
12092
12093
1/2
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
304 if (ret)
12094 {
12095 return qe_invalid;
12096 }
12097 304 }
12098 38 }
12099
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 77 times.
77 else if(s_version > 13)
12100 {
12101 for(int32_t i = 0; i < NUMSCRIPTGLOBAL255OLD; ++i)
12102 {
12103 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &globalscripts[i], zmeta_version);
12104
12105 if (ret)
12106 {
12107 return qe_invalid;
12108 }
12109 }
12110
12111 if(globalscripts[GLOBAL_SCRIPT_ONSAVE] != NULL)
12112 delete globalscripts[GLOBAL_SCRIPT_ONSAVE];
12113
12114 globalscripts[GLOBAL_SCRIPT_ONSAVE] = new script_data(ScriptType::Global, GLOBAL_SCRIPT_ONSAVE);
12115 }
12116
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 else if(s_version > 4)
12117 {
12118
2/2
✓ Branch 0 taken 308 times.
✓ Branch 1 taken 77 times.
385 for(int32_t i = 0; i < NUMSCRIPTGLOBAL253; ++i)
12119 {
12120 308 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &globalscripts[i], zmeta_version);
12121
12122
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if (ret)
12123 {
12124 return qe_invalid;
12125 }
12126 308 }
12127
12128
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 77 times.
77 if(globalscripts[GLOBAL_SCRIPT_ONLAUNCH] != NULL)
12129
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 delete globalscripts[GLOBAL_SCRIPT_ONLAUNCH];
12130
12131
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 globalscripts[GLOBAL_SCRIPT_ONLAUNCH] = new script_data(ScriptType::Global, GLOBAL_SCRIPT_ONLAUNCH);
12132
12133
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 77 times.
77 if(globalscripts[GLOBAL_SCRIPT_ONCONTGAME] != NULL)
12134
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 delete globalscripts[GLOBAL_SCRIPT_ONCONTGAME];
12135
12136
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 globalscripts[GLOBAL_SCRIPT_ONCONTGAME] = new script_data(ScriptType::Global, GLOBAL_SCRIPT_ONCONTGAME);
12137
12138
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 77 times.
77 if(globalscripts[GLOBAL_SCRIPT_F6] != NULL)
12139
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 delete globalscripts[GLOBAL_SCRIPT_F6];
12140
12141
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 globalscripts[GLOBAL_SCRIPT_F6] = new script_data(ScriptType::Global, GLOBAL_SCRIPT_F6);
12142
12143
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 77 times.
77 if(globalscripts[GLOBAL_SCRIPT_ONSAVE] != NULL)
12144
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 delete globalscripts[GLOBAL_SCRIPT_ONSAVE];
12145
12146
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 globalscripts[GLOBAL_SCRIPT_ONSAVE] = new script_data(ScriptType::Global, GLOBAL_SCRIPT_ONSAVE);
12147 77 }
12148 else
12149 {
12150 for(int32_t i = 0; i < NUMSCRIPTGLOBALOLD; i++)
12151 {
12152 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &globalscripts[i], zmeta_version);
12153
12154 if (ret)
12155 {
12156 return qe_invalid;
12157 }
12158 }
12159
12160 if(globalscripts[GLOBAL_SCRIPT_ONSAVELOAD] != NULL)
12161 delete globalscripts[GLOBAL_SCRIPT_ONSAVELOAD];
12162
12163 globalscripts[GLOBAL_SCRIPT_ONSAVELOAD] = new script_data(ScriptType::Global, GLOBAL_SCRIPT_ONSAVELOAD);
12164
12165 if(globalscripts[GLOBAL_SCRIPT_ONLAUNCH] != NULL)
12166 delete globalscripts[GLOBAL_SCRIPT_ONLAUNCH];
12167
12168 globalscripts[GLOBAL_SCRIPT_ONLAUNCH] = new script_data(ScriptType::Global, GLOBAL_SCRIPT_ONLAUNCH);
12169
12170 if(globalscripts[GLOBAL_SCRIPT_ONCONTGAME] != NULL)
12171 delete globalscripts[GLOBAL_SCRIPT_ONCONTGAME];
12172
12173 globalscripts[GLOBAL_SCRIPT_ONCONTGAME] = new script_data(ScriptType::Global, GLOBAL_SCRIPT_ONCONTGAME);
12174
12175 if(globalscripts[GLOBAL_SCRIPT_F6] != NULL)
12176 delete globalscripts[GLOBAL_SCRIPT_F6];
12177
12178 globalscripts[GLOBAL_SCRIPT_F6] = new script_data(ScriptType::Global, GLOBAL_SCRIPT_F6);
12179
12180 if(globalscripts[GLOBAL_SCRIPT_ONSAVE] != NULL)
12181 delete globalscripts[GLOBAL_SCRIPT_ONSAVE];
12182
12183 globalscripts[GLOBAL_SCRIPT_ONSAVE] = new script_data(ScriptType::Global, GLOBAL_SCRIPT_ONSAVE);
12184 }
12185
12186
2/2
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 77 times.
115 if(s_version > 10) //expanded the number of Player scripts to 5.
12187 {
12188
2/2
✓ Branch 0 taken 190 times.
✓ Branch 1 taken 38 times.
228 for(int32_t i = 0; i < NUMSCRIPTPLAYER; i++)
12189 {
12190 190 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &playerscripts[i], zmeta_version);
12191
12192
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 if (ret)
12193 {
12194 return qe_invalid;
12195 }
12196 190 }
12197 38 }
12198 else
12199 {
12200
2/2
✓ Branch 0 taken 231 times.
✓ Branch 1 taken 77 times.
308 for(int32_t i = 0; i < NUMSCRIPTHEROOLD; i++)
12201 {
12202 231 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &playerscripts[i], zmeta_version);
12203
12204
1/2
✓ Branch 0 taken 231 times.
✗ Branch 1 not taken.
231 if (ret)
12205 {
12206 return qe_invalid;
12207 }
12208 231 }
12209
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 if(playerscripts[3] != NULL)
12210
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 delete playerscripts[3];
12211
12212
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 playerscripts[3] = new script_data(ScriptType::Player, 3);
12213
12214
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 if(playerscripts[4] != NULL)
12215
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 77 times.
77 delete playerscripts[4];
12216
12217
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 playerscripts[4] = new script_data(ScriptType::Player, 4);
12218 }
12219
3/4
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 77 times.
✓ Branch 2 taken 38 times.
✗ Branch 3 not taken.
115 if(s_version > 8 && s_version < 10)
12220 {
12221
12222 for(int32_t i = 0; i < NUMSCRIPTWEAPONS; i++)
12223 {
12224 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &ewpnscripts[i], zmeta_version);
12225
12226 if (ret)
12227 {
12228 return qe_invalid;
12229 }
12230 }
12231 for(int32_t i = 0; i < NUMSCRIPTSDMAP; i++)
12232 {
12233 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &dmapscripts[i], zmeta_version);
12234
12235 if (ret)
12236 {
12237 return qe_invalid;
12238 }
12239 }
12240
12241 }
12242
2/2
✓ Branch 0 taken 77 times.
✓ Branch 1 taken 38 times.
115 if(s_version >= 10)
12243 {
12244
2/2
✓ Branch 0 taken 9728 times.
✓ Branch 1 taken 38 times.
9766 for(int32_t i = 0; i < NUMSCRIPTWEAPONS; i++)
12245 {
12246 9728 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &lwpnscripts[i], zmeta_version);
12247
12248
1/2
✓ Branch 0 taken 9728 times.
✗ Branch 1 not taken.
9728 if (ret)
12249 {
12250 return qe_invalid;
12251 }
12252 9728 }
12253
2/2
✓ Branch 0 taken 9728 times.
✓ Branch 1 taken 38 times.
9766 for(int32_t i = 0; i < NUMSCRIPTWEAPONS; i++)
12254 {
12255 9728 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &ewpnscripts[i], zmeta_version);
12256
12257
1/2
✓ Branch 0 taken 9728 times.
✗ Branch 1 not taken.
9728 if (ret)
12258 {
12259 return qe_invalid;
12260 }
12261 9728 }
12262
2/2
✓ Branch 0 taken 9728 times.
✓ Branch 1 taken 38 times.
9766 for(int32_t i = 0; i < NUMSCRIPTSDMAP; i++)
12263 {
12264 9728 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &dmapscripts[i], zmeta_version);
12265
12266
1/2
✓ Branch 0 taken 9728 times.
✗ Branch 1 not taken.
9728 if (ret)
12267 {
12268 return qe_invalid;
12269 }
12270 9728 }
12271
12272 38 }
12273
2/2
✓ Branch 0 taken 77 times.
✓ Branch 1 taken 38 times.
115 if(s_version >=12)
12274 {
12275
2/2
✓ Branch 0 taken 9728 times.
✓ Branch 1 taken 38 times.
9766 for(int32_t i = 0; i < NUMSCRIPTSITEMSPRITE; i++)
12276 {
12277 9728 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &itemspritescripts[i], zmeta_version);
12278
12279
1/2
✓ Branch 0 taken 9728 times.
✗ Branch 1 not taken.
9728 if (ret)
12280 {
12281 return qe_invalid;
12282 }
12283 9728 }
12284 38 }
12285
2/2
✓ Branch 0 taken 77 times.
✓ Branch 1 taken 38 times.
115 if(s_version >=15)
12286 {
12287
2/2
✓ Branch 0 taken 19456 times.
✓ Branch 1 taken 38 times.
19494 for(int32_t i = 0; i < NUMSCRIPTSCOMBODATA; i++)
12288 {
12289 19456 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &comboscripts[i], zmeta_version);
12290
12291
1/2
✓ Branch 0 taken 19456 times.
✗ Branch 1 not taken.
19456 if (ret)
12292 {
12293 return qe_invalid;
12294 }
12295 19456 }
12296 38 }
12297
2/2
✓ Branch 0 taken 77 times.
✓ Branch 1 taken 38 times.
115 if(s_version >19)
12298 {
12299 38 word numgenscripts = NUMSCRIPTSGENERIC;
12300
1/2
✓ Branch 0 taken 38 times.
✗ Branch 1 not taken.
38 if(!p_igetw(&numgenscripts,f))
12301 {
12302 return qe_invalid;
12303 }
12304
2/2
✓ Branch 0 taken 19456 times.
✓ Branch 1 taken 38 times.
19494 for(int32_t i = 0; i < numgenscripts; i++)
12305 {
12306 19456 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &genericscripts[i], zmeta_version);
12307
12308
1/2
✓ Branch 0 taken 19456 times.
✗ Branch 1 not taken.
19456 if (ret)
12309 {
12310 return qe_invalid;
12311 }
12312 19456 }
12313 38 }
12314
2/2
✓ Branch 0 taken 86 times.
✓ Branch 1 taken 29 times.
115 if(s_version >21)
12315 {
12316 29 word numsubscripts = NUMSCRIPTSSUBSCREEN;
12317
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29 if(!p_igetw(&numsubscripts,f))
12318 {
12319 return qe_invalid;
12320 }
12321
2/2
✓ Branch 0 taken 7424 times.
✓ Branch 1 taken 29 times.
7453 for(int32_t i = 0; i < numsubscripts; i++)
12322 {
12323 7424 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &subscreenscripts[i], zmeta_version);
12324
12325
1/2
✓ Branch 0 taken 7424 times.
✗ Branch 1 not taken.
7424 if (ret)
12326 {
12327 return qe_invalid;
12328 }
12329 7424 }
12330 29 }
12331 115 }
12332
12333
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 115 times.
115 if(s_version > 2)
12334 {
12335 int32_t bufsize;
12336 115 p_igetl(&bufsize, f);
12337
2/4
✓ Branch 0 taken 115 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 115 times.
115 if (bufsize < 0 || bufsize > 1024*1024*10)
12338 {
12339 // God help anyone storing more than 10MB of code in the script buffer.
12340 return qe_invalid;
12341 }
12342 115 char * buf = new char[bufsize+1];
12343 115 pfread(buf, bufsize, f);
12344 115 buf[bufsize]=0;
12345
12346
1/2
✓ Branch 0 taken 115 times.
✗ Branch 1 not taken.
115 zScript = string(buf);
12347
12348
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 115 times.
115 delete[] buf;
12349 word numffcbindings;
12350 115 p_igetw(&numffcbindings, f);
12351
12352
2/2
✓ Branch 0 taken 1597 times.
✓ Branch 1 taken 115 times.
1712 for(int32_t i=0; i<numffcbindings; i++)
12353 {
12354 word id;
12355 1597 p_igetw(&id, f);
12356 1597 p_igetl(&bufsize, f);
12357
2/4
✓ Branch 0 taken 1597 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1597 times.
1597 if (bufsize < 0 || bufsize > 1024)
12358 return qe_invalid;
12359 1597 buf = new char[bufsize+1];
12360 1597 pfread(buf, bufsize, f);
12361 1597 buf[bufsize]=0;
12362
12363 //fix for buggy older saved quests -DD
12364
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1597 times.
1597 if(id < NUMSCRIPTFFC-1)
12365 1597 ffcmap[id].scriptname = buf;
12366
12367
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1597 times.
1597 delete[] buf;
12368 1597 }
12369
12370 word numglobalbindings;
12371 115 p_igetw(&numglobalbindings, f);
12372
12373
2/2
✓ Branch 0 taken 441 times.
✓ Branch 1 taken 115 times.
556 for(int32_t i=0; i<numglobalbindings; i++)
12374 {
12375 word id;
12376 441 p_igetw(&id, f);
12377 441 p_igetl(&bufsize, f);
12378
2/4
✓ Branch 0 taken 441 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 441 times.
✗ Branch 3 not taken.
441 if (bufsize < 0 || bufsize > 1024)
12379 return qe_invalid;
12380 441 buf = new char[bufsize+1];
12381 441 pfread(buf, bufsize, f);
12382 441 buf[bufsize]=0;
12383
12384 // id in principle should be valid, since slot assignment cannot assign a global script to a bogus slot.
12385 // However, because of a corruption bug, some 2.50.x quests contain bogus entries in the global bindings table.
12386 // Ignore these. -DD
12387
3/4
✓ Branch 0 taken 441 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 159 times.
✓ Branch 3 taken 282 times.
441 if(id >= 0 && id < NUMSCRIPTGLOBAL)
12388 {
12389 //Disable old '~Continue's, they'd wreak havoc. Bit messy, apologies ~Joe
12390
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 if(strcmp(buf,"~Continue") == 0)
12391 {
12392 globalmap[id].scriptname = "";
12393
12394 if(globalscripts[GLOBAL_SCRIPT_ONSAVELOAD] != NULL)
12395 globalscripts[GLOBAL_SCRIPT_ONSAVELOAD]->disable();
12396 }
12397 else
12398 {
12399 282 globalmap[id].scriptname = buf;
12400 }
12401 282 }
12402
12403
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 441 times.
441 delete[] buf;
12404 441 }
12405
12406
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 115 times.
115 if(s_version > 3)
12407 {
12408 word numitembindings;
12409 115 p_igetw(&numitembindings, f);
12410
12411
2/2
✓ Branch 0 taken 98 times.
✓ Branch 1 taken 115 times.
213 for(int32_t i=0; i<numitembindings; i++)
12412 {
12413 word id;
12414 98 p_igetw(&id, f);
12415 98 p_igetl(&bufsize, f);
12416
2/4
✓ Branch 0 taken 98 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 98 times.
98 if (bufsize < 0 || bufsize > 1024)
12417 return qe_invalid;
12418 98 buf = new char[bufsize+1];
12419 98 pfread(buf, bufsize, f);
12420 98 buf[bufsize]=0;
12421
12422 //fix this too
12423
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 98 times.
98 if(id <NUMSCRIPTITEM-1)
12424 98 itemmap[id].scriptname = buf;
12425
12426
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 98 times.
98 delete[] buf;
12427 98 }
12428 115 }
12429 //(v9+)
12430
2/2
✓ Branch 0 taken 77 times.
✓ Branch 1 taken 38 times.
115 if(s_version > 8)
12431 {
12432 //npc scripts
12433 word numnpcbindings;
12434 38 p_igetw(&numnpcbindings, f);
12435
12436
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 38 times.
50 for(int32_t i=0; i<numnpcbindings; i++)
12437 {
12438 word id;
12439 12 p_igetw(&id, f);
12440 12 p_igetl(&bufsize, f);
12441
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if (bufsize < 0 || bufsize > 1024)
12442 return qe_invalid;
12443 12 buf = new char[bufsize+1];
12444 12 pfread(buf, bufsize, f);
12445 12 buf[bufsize]=0;
12446
12447 //fix this too
12448
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(id <NUMSCRIPTGUYS-1)
12449 12 npcmap[id].scriptname = buf;
12450
12451
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 delete[] buf;
12452 12 }
12453 //lweapon
12454 word numlwpnbindings;
12455 38 p_igetw(&numlwpnbindings, f);
12456
12457
2/2
✓ Branch 0 taken 42 times.
✓ Branch 1 taken 38 times.
80 for(int32_t i=0; i<numlwpnbindings; i++)
12458 {
12459 word id;
12460 42 p_igetw(&id, f);
12461 42 p_igetl(&bufsize, f);
12462
2/4
✓ Branch 0 taken 42 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 42 times.
✗ Branch 3 not taken.
42 if (bufsize < 0 || bufsize > 1024)
12463 return qe_invalid;
12464 42 buf = new char[bufsize+1];
12465 42 pfread(buf, bufsize, f);
12466 42 buf[bufsize]=0;
12467
12468 //fix this too
12469
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 42 times.
42 if(id <NUMSCRIPTWEAPONS-1)
12470 42 lwpnmap[id].scriptname = buf;
12471
12472
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 42 times.
42 delete[] buf;
12473 42 }
12474 //eweapon
12475 word numewpnbindings;
12476 38 p_igetw(&numewpnbindings, f);
12477
12478
2/2
✓ Branch 0 taken 63 times.
✓ Branch 1 taken 38 times.
101 for(int32_t i=0; i<numewpnbindings; i++)
12479 {
12480 word id;
12481 63 p_igetw(&id, f);
12482 63 p_igetl(&bufsize, f);
12483
2/4
✓ Branch 0 taken 63 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 63 times.
✗ Branch 3 not taken.
63 if (bufsize < 0 || bufsize > 1024)
12484 return qe_invalid;
12485 63 buf = new char[bufsize+1];
12486 63 pfread(buf, bufsize, f);
12487 63 buf[bufsize]=0;
12488
12489 //fix this too
12490
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 63 times.
63 if(id <NUMSCRIPTWEAPONS-1)
12491 63 ewpnmap[id].scriptname = buf;
12492
12493
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 63 times.
63 delete[] buf;
12494 63 }
12495 //hero
12496 word numherobindings;
12497 38 p_igetw(&numherobindings, f);
12498
12499
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 38 times.
43 for(int32_t i=0; i<numherobindings; i++)
12500 {
12501 word id;
12502 5 p_igetw(&id, f);
12503 5 p_igetl(&bufsize, f);
12504
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
5 if (bufsize < 0 || bufsize > 1024)
12505 return qe_invalid;
12506 5 buf = new char[bufsize+1];
12507 5 pfread(buf, bufsize, f);
12508 5 buf[bufsize]=0;
12509
12510 //fix this too
12511
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 if(id <NUMSCRIPTPLAYER-1)
12512 5 playermap[id].scriptname = buf;
12513
12514
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 delete[] buf;
12515 5 }
12516 //dmaps
12517 word numdmapbindings;
12518 38 p_igetw(&numdmapbindings, f);
12519
12520
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 38 times.
73 for(int32_t i=0; i<numdmapbindings; i++)
12521 {
12522 word id;
12523 35 p_igetw(&id, f);
12524 35 p_igetl(&bufsize, f);
12525
2/4
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 35 times.
✗ Branch 3 not taken.
35 if (bufsize < 0 || bufsize > 1024)
12526 return qe_invalid;
12527 35 buf = new char[bufsize+1];
12528 35 pfread(buf, bufsize, f);
12529 35 buf[bufsize]=0;
12530
12531 //fix this too
12532
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35 times.
35 if(id <NUMSCRIPTSDMAP-1)
12533 35 dmapmap[id].scriptname = buf;
12534
12535
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35 times.
35 delete[] buf;
12536 35 }
12537 //screen
12538 word numscreenbindings;
12539 38 p_igetw(&numscreenbindings, f);
12540
12541
2/2
✓ Branch 0 taken 39 times.
✓ Branch 1 taken 38 times.
77 for(int32_t i=0; i<numscreenbindings; i++)
12542 {
12543 word id;
12544 39 p_igetw(&id, f);
12545 39 p_igetl(&bufsize, f);
12546
2/4
✓ Branch 0 taken 39 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 39 times.
✗ Branch 3 not taken.
39 if (bufsize < 0 || bufsize > 1024)
12547 return qe_invalid;
12548 39 buf = new char[bufsize+1];
12549 39 pfread(buf, bufsize, f);
12550 39 buf[bufsize]=0;
12551
12552 //fix this too
12553
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 39 times.
39 if(id <NUMSCRIPTSDMAP-1)
12554 39 screenmap[id].scriptname = buf;
12555
12556
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 39 times.
39 delete[] buf;
12557 39 }
12558 38 }
12559
2/2
✓ Branch 0 taken 77 times.
✓ Branch 1 taken 38 times.
115 if(s_version > 11)
12560 {
12561 word numspritebindings;
12562 38 p_igetw(&numspritebindings, f);
12563
12564
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 38 times.
48 for(int32_t i=0; i<numspritebindings; i++)
12565 {
12566 word id;
12567 10 p_igetw(&id, f);
12568 10 p_igetl(&bufsize, f);
12569
2/4
✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 10 times.
✗ Branch 3 not taken.
10 if (bufsize < 0 || bufsize > 1024)
12570 return qe_invalid;
12571 10 buf = new char[bufsize+1];
12572 10 pfread(buf, bufsize, f);
12573 10 buf[bufsize]=0;
12574
12575 //fix this too
12576
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10 times.
10 if(id <NUMSCRIPTSDMAP-1)
12577 10 itemspritemap[id].scriptname = buf;
12578
12579
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10 times.
10 delete[] buf;
12580 10 }
12581 38 }
12582
2/2
✓ Branch 0 taken 77 times.
✓ Branch 1 taken 38 times.
115 if(s_version >= 15)
12583 {
12584 word numcombobindings;
12585 38 p_igetw(&numcombobindings, f);
12586
12587
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 38 times.
61 for(int32_t i=0; i<numcombobindings; i++)
12588 {
12589 word id;
12590 23 p_igetw(&id, f);
12591 23 p_igetl(&bufsize, f);
12592
2/4
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 23 times.
23 if (bufsize < 0 || bufsize > 1024)
12593 return qe_invalid;
12594 23 buf = new char[bufsize+1];
12595 23 pfread(buf, bufsize, f);
12596 23 buf[bufsize]=0;
12597
12598 //fix this too
12599
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 23 times.
23 if(id <NUMSCRIPTSCOMBODATA-1)
12600 23 comboscriptmap[id].scriptname = buf;
12601
12602
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 23 times.
23 delete[] buf;
12603 23 }
12604 38 }
12605
2/2
✓ Branch 0 taken 77 times.
✓ Branch 1 taken 38 times.
115 if(s_version > 19)
12606 {
12607 word numgenericbindings;
12608 38 p_igetw(&numgenericbindings, f);
12609
12610
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 38 times.
51 for(int32_t i=0; i<numgenericbindings; i++)
12611 {
12612 word id;
12613 13 p_igetw(&id, f);
12614 13 p_igetl(&bufsize, f);
12615
2/4
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 13 times.
13 if (bufsize < 0 || bufsize > 1024)
12616 return qe_invalid;
12617 13 buf = new char[bufsize+1];
12618 13 pfread(buf, bufsize, f);
12619 13 buf[bufsize]=0;
12620
12621 //fix this too
12622
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 if(id <NUMSCRIPTSGENERIC-1)
12623 13 genericmap[id].scriptname = buf;
12624
12625
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 delete[] buf;
12626 13 }
12627 38 }
12628
2/2
✓ Branch 0 taken 86 times.
✓ Branch 1 taken 29 times.
115 if(s_version > 21)
12629 {
12630 word numsubscreenbindings;
12631 29 p_igetw(&numsubscreenbindings, f);
12632
12633
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29 times.
29 for(int32_t i=0; i<numsubscreenbindings; i++)
12634 {
12635 word id;
12636 p_igetw(&id, f);
12637 p_igetl(&bufsize, f);
12638 if (bufsize < 0 || bufsize > 1024)
12639 return qe_invalid;
12640 buf = new char[bufsize+1];
12641 pfread(buf, bufsize, f);
12642 buf[bufsize]=0;
12643
12644 //fix this too
12645 if(id <NUMSCRIPTSSUBSCREEN-1)
12646 subscreenmap[id].scriptname = buf;
12647
12648 delete[] buf;
12649 }
12650 29 }
12651 115 }
12652
12653 115 return 0;
12654 115 }
12655
12656 131 void reset_scripts()
12657 {
12658 #ifdef IS_PLAYER
12659 // We can't modify the script data while jit threads are possibly compiling them.
12660 void jit_shutdown();
12661 131 jit_shutdown();
12662 #endif
12663
12664
2/2
✓ Branch 0 taken 67072 times.
✓ Branch 1 taken 131 times.
67203 for(int32_t i=0; i<NUMSCRIPTSGENERIC; i++)
12665 {
12666
1/2
✓ Branch 0 taken 67072 times.
✗ Branch 1 not taken.
67072 if (genericscripts[i]!=NULL) genericscripts[i]->disable();
12667 else genericscripts[i] = new script_data({ScriptType::Generic, i});
12668 67072 }
12669
12670
2/2
✓ Branch 0 taken 67072 times.
✓ Branch 1 taken 131 times.
67203 for(int32_t i=0; i<NUMSCRIPTFFC; i++)
12671 {
12672
1/2
✓ Branch 0 taken 67072 times.
✗ Branch 1 not taken.
67072 if (ffscripts[i])
12673 67072 ffscripts[i]->disable();
12674 else
12675 ffscripts[i] = new script_data(ScriptType::FFC, i);
12676 67072 }
12677
12678
2/2
✓ Branch 0 taken 33536 times.
✓ Branch 1 taken 131 times.
33667 for(int32_t i=0; i<NUMSCRIPTITEM; i++)
12679 {
12680
1/2
✓ Branch 0 taken 33536 times.
✗ Branch 1 not taken.
33536 if (itemscripts[i])
12681 33536 itemscripts[i]->disable();
12682 else
12683 itemscripts[i] = new script_data(ScriptType::Item, i);
12684 33536 }
12685
12686
2/2
✓ Branch 0 taken 33536 times.
✓ Branch 1 taken 131 times.
33667 for(int32_t i=0; i<NUMSCRIPTGUYS; i++)
12687 {
12688
1/2
✓ Branch 0 taken 33536 times.
✗ Branch 1 not taken.
33536 if (guyscripts[i])
12689 33536 guyscripts[i]->disable();
12690 else
12691 guyscripts[i] = new script_data(ScriptType::NPC, i);
12692 33536 }
12693
12694
2/2
✓ Branch 0 taken 33536 times.
✓ Branch 1 taken 131 times.
33667 for(int32_t i=0; i<NUMSCRIPTSCREEN; i++)
12695 {
12696
1/2
✓ Branch 0 taken 33536 times.
✗ Branch 1 not taken.
33536 if (screenscripts[i])
12697 33536 screenscripts[i]->disable();
12698 else
12699 screenscripts[i] = new script_data(ScriptType::Screen, i);
12700 33536 }
12701
12702
2/2
✓ Branch 0 taken 1048 times.
✓ Branch 1 taken 131 times.
1179 for(int32_t i=0; i<NUMSCRIPTGLOBAL; i++)
12703 {
12704
1/2
✓ Branch 0 taken 1048 times.
✗ Branch 1 not taken.
1048 if (globalscripts[i])
12705 1048 globalscripts[i]->disable();
12706 else
12707 globalscripts[i] = new script_data(ScriptType::Global, i);
12708 1048 }
12709
12710
2/2
✓ Branch 0 taken 655 times.
✓ Branch 1 taken 131 times.
786 for(int32_t i=0; i<NUMSCRIPTPLAYER; i++)
12711 {
12712
1/2
✓ Branch 0 taken 655 times.
✗ Branch 1 not taken.
655 if (playerscripts[i])
12713 655 playerscripts[i]->disable();
12714 else
12715 playerscripts[i] = new script_data(ScriptType::Player, i);
12716 655 }
12717
12718
2/2
✓ Branch 0 taken 33536 times.
✓ Branch 1 taken 131 times.
33667 for(int32_t i=0; i<NUMSCRIPTWEAPONS; i++)
12719 {
12720
1/2
✓ Branch 0 taken 33536 times.
✗ Branch 1 not taken.
33536 if (lwpnscripts[i])
12721 33536 lwpnscripts[i]->disable();
12722 else
12723 lwpnscripts[i] = new script_data(ScriptType::Lwpn, i);
12724 33536 }
12725
2/2
✓ Branch 0 taken 33536 times.
✓ Branch 1 taken 131 times.
33667 for(int32_t i=0; i<NUMSCRIPTWEAPONS; i++)
12726 {
12727
1/2
✓ Branch 0 taken 33536 times.
✗ Branch 1 not taken.
33536 if (ewpnscripts[i])
12728 33536 ewpnscripts[i]->disable();
12729 else
12730 ewpnscripts[i] = new script_data(ScriptType::Ewpn, i);
12731 33536 }
12732
12733
2/2
✓ Branch 0 taken 33536 times.
✓ Branch 1 taken 131 times.
33667 for(int32_t i=0; i<NUMSCRIPTSDMAP; i++)
12734 {
12735
1/2
✓ Branch 0 taken 33536 times.
✗ Branch 1 not taken.
33536 if (dmapscripts[i])
12736 33536 dmapscripts[i]->disable();
12737 else
12738 dmapscripts[i] = new script_data(ScriptType::DMap, i);
12739 33536 }
12740
2/2
✓ Branch 0 taken 33536 times.
✓ Branch 1 taken 131 times.
33667 for(int32_t i=0; i<NUMSCRIPTSITEMSPRITE; i++)
12741 {
12742
1/2
✓ Branch 0 taken 33536 times.
✗ Branch 1 not taken.
33536 if (itemspritescripts[i])
12743 33536 itemspritescripts[i]->disable();
12744 else
12745 itemspritescripts[i] = new script_data(ScriptType::ItemSprite, i);
12746 33536 }
12747
2/2
✓ Branch 0 taken 67072 times.
✓ Branch 1 taken 131 times.
67203 for(int32_t i=0; i<NUMSCRIPTSCOMBODATA; i++)
12748 {
12749
1/2
✓ Branch 0 taken 67072 times.
✗ Branch 1 not taken.
67072 if (comboscripts[i])
12750 67072 comboscripts[i]->disable();
12751 else
12752 comboscripts[i] = new script_data(ScriptType::Combo, i);
12753 67072 }
12754
2/2
✓ Branch 0 taken 33536 times.
✓ Branch 1 taken 131 times.
33667 for(int32_t i=0; i<NUMSCRIPTSSUBSCREEN; i++)
12755 {
12756
1/2
✓ Branch 0 taken 33536 times.
✗ Branch 1 not taken.
33536 if (subscreenscripts[i])
12757 33536 subscreenscripts[i]->disable();
12758 else
12759 subscreenscripts[i] = new script_data(ScriptType::EngineSubscreen, i);
12760 33536 }
12761 131 }
12762
12763 extern script_command command_list[];
12764 262921 int32_t read_one_ffscript(PACKFILE *f, zquestheader *, int32_t script_index, word s_version, word , script_data **script, word zmeta_version)
12765 {
12766 // TODO: refactor to just take a script_data*
12767
1/2
✓ Branch 0 taken 262921 times.
✗ Branch 1 not taken.
262921 ASSERT(*script);
12768
12769 //Please also update loadquest() when modifying this method -DD
12770 262921 char b33[34] = {0};
12771 262921 b33[33] = 0;
12772 262921 ffscript temp_script;
12773 262921 int32_t num_commands=1000;
12774
12775
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 262921 times.
262921 if(s_version>=2)
12776 {
12777
2/4
✓ Branch 0 taken 262921 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 262921 times.
✗ Branch 3 not taken.
262921 if(!p_igetl(&num_commands,f))
12778 {
12779 return qe_invalid;
12780 }
12781 262921 }
12782
12783 #ifdef ZC_FUZZ
12784 const int32_t command_limit = 300000;
12785 #else
12786 262921 const int32_t command_limit = 10000000;
12787 #endif
12788
2/4
✓ Branch 0 taken 262921 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 262921 times.
✗ Branch 3 not taken.
262921 if (num_commands < 0 || num_commands > command_limit)
12789 {
12790 return qe_invalid;
12791 }
12792
12793
1/2
✓ Branch 0 taken 262921 times.
✗ Branch 1 not taken.
262921 (*script)->null_script(num_commands);
12794
12795
2/2
✓ Branch 0 taken 144110 times.
✓ Branch 1 taken 118811 times.
262921 if(s_version >= 16)
12796 {
12797
1/2
✓ Branch 0 taken 144110 times.
✗ Branch 1 not taken.
144110 zasm_meta temp_meta;
12798
12799
2/4
✓ Branch 0 taken 144110 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 144110 times.
✗ Branch 3 not taken.
144110 if(!p_igetw(&(temp_meta.zasm_v),f))
12800 {
12801 return qe_invalid;
12802 }
12803
12804
2/4
✓ Branch 0 taken 144110 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 144110 times.
✗ Branch 3 not taken.
144110 if(!p_igetw(&(temp_meta.meta_v),f))
12805 {
12806 return qe_invalid;
12807 }
12808
12809
2/4
✓ Branch 0 taken 144110 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 144110 times.
✗ Branch 3 not taken.
144110 if(!p_igetw(&(temp_meta.ffscript_v),f))
12810 {
12811 return qe_invalid;
12812 }
12813
12814
2/4
✓ Branch 0 taken 144110 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 144110 times.
✗ Branch 3 not taken.
144110 if(!p_getc(&(temp_meta.script_type),f))
12815 {
12816 return qe_invalid;
12817 }
12818
12819
2/2
✓ Branch 0 taken 1152880 times.
✓ Branch 1 taken 144110 times.
1296990 for(int32_t q = 0; q < 8; ++q)
12820 {
12821
2/2
✓ Branch 0 taken 57552 times.
✓ Branch 1 taken 1095328 times.
1152880 if(zmeta_version < 3)
12822 {
12823
2/2
✓ Branch 0 taken 57552 times.
✓ Branch 1 taken 1899216 times.
1956768 for(int32_t c = 0; c < 33; ++c)
12824 {
12825
2/4
✓ Branch 0 taken 1899216 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1899216 times.
✗ Branch 3 not taken.
1899216 if(!p_getc(&(b33[c]),f))
12826 {
12827 return qe_invalid;
12828 }
12829 1899216 }
12830
1/2
✓ Branch 0 taken 57552 times.
✗ Branch 1 not taken.
57552 temp_meta.run_idens[q].assign(b33);
12831 57552 }
12832 else
12833 {
12834
2/4
✓ Branch 0 taken 1095328 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1095328 times.
✗ Branch 3 not taken.
1095328 if(!p_getcstr(&temp_meta.run_idens[q],f))
12835 {
12836 return qe_invalid;
12837 }
12838 }
12839 1152880 }
12840
12841
2/2
✓ Branch 0 taken 144110 times.
✓ Branch 1 taken 1152880 times.
1296990 for(int32_t q = 0; q < 8; ++q)
12842 {
12843
2/4
✓ Branch 0 taken 1152880 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1152880 times.
✗ Branch 3 not taken.
1152880 if(!p_getc(&(temp_meta.run_types[q]),f))
12844 {
12845 return qe_invalid;
12846 }
12847 1152880 }
12848
12849
2/4
✓ Branch 0 taken 144110 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 144110 times.
✗ Branch 3 not taken.
144110 if(!p_getc(&(temp_meta.flags),f))
12850 {
12851 return qe_invalid;
12852 }
12853
12854
2/4
✓ Branch 0 taken 144110 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 144110 times.
✗ Branch 3 not taken.
144110 if(!p_igetw(&(temp_meta.compiler_v1),f))
12855 {
12856 return qe_invalid;
12857 }
12858
12859
2/4
✓ Branch 0 taken 144110 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 144110 times.
✗ Branch 3 not taken.
144110 if(!p_igetw(&(temp_meta.compiler_v2),f))
12860 {
12861 return qe_invalid;
12862 }
12863
12864
2/4
✓ Branch 0 taken 144110 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 144110 times.
✗ Branch 3 not taken.
144110 if(!p_igetw(&(temp_meta.compiler_v3),f))
12865 {
12866 return qe_invalid;
12867 }
12868
12869
2/4
✓ Branch 0 taken 144110 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 144110 times.
✗ Branch 3 not taken.
144110 if(!p_igetw(&(temp_meta.compiler_v4),f))
12870 {
12871 return qe_invalid;
12872 }
12873
12874
2/2
✓ Branch 0 taken 7194 times.
✓ Branch 1 taken 136916 times.
144110 if(zmeta_version == 2)
12875 {
12876
2/2
✓ Branch 0 taken 7194 times.
✓ Branch 1 taken 237402 times.
244596 for(int32_t c = 0; c < 33; ++c)
12877 {
12878
2/4
✓ Branch 0 taken 237402 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 237402 times.
✗ Branch 3 not taken.
237402 if(!p_getc(&b33[c],f))
12879 {
12880 return qe_invalid;
12881 }
12882 237402 }
12883
1/2
✓ Branch 0 taken 7194 times.
✗ Branch 1 not taken.
7194 temp_meta.script_name.assign(b33);
12884
12885
2/2
✓ Branch 0 taken 7194 times.
✓ Branch 1 taken 237402 times.
244596 for(int32_t c = 0; c < 33; ++c)
12886 {
12887
2/4
✓ Branch 0 taken 237402 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 237402 times.
✗ Branch 3 not taken.
237402 if(!p_getc(&b33[c],f))
12888 {
12889 return qe_invalid;
12890 }
12891 237402 }
12892
1/2
✓ Branch 0 taken 7194 times.
✗ Branch 1 not taken.
7194 temp_meta.author.assign(b33);
12893 7194 }
12894
1/2
✓ Branch 0 taken 136916 times.
✗ Branch 1 not taken.
136916 else if(zmeta_version > 2)
12895 {
12896
2/4
✓ Branch 0 taken 136916 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 136916 times.
✗ Branch 3 not taken.
136916 if(!p_getcstr(&temp_meta.script_name,f))
12897 return qe_invalid;
12898
2/4
✓ Branch 0 taken 136916 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 136916 times.
✗ Branch 3 not taken.
136916 if(!p_getcstr(&temp_meta.author,f))
12899 return qe_invalid;
12900 136916 auto num_meta_attrib = (zmeta_version < 5 ? 4 : 10);
12901
2/2
✓ Branch 0 taken 1369160 times.
✓ Branch 1 taken 136916 times.
1506076 for(auto q = 0; q < num_meta_attrib; ++q)
12902 {
12903
2/4
✓ Branch 0 taken 1369160 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1369160 times.
✗ Branch 3 not taken.
1369160 if(!p_getcstr(&temp_meta.attributes[q],f))
12904 return qe_invalid;
12905
2/4
✓ Branch 0 taken 1369160 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1369160 times.
✗ Branch 3 not taken.
1369160 if(!p_getwstr(&temp_meta.attributes_help[q],f))
12906 return qe_invalid;
12907 1369160 }
12908
2/2
✓ Branch 0 taken 1095328 times.
✓ Branch 1 taken 136916 times.
1232244 for(auto q = 0; q < 8; ++q)
12909 {
12910
2/4
✓ Branch 0 taken 1095328 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1095328 times.
✗ Branch 3 not taken.
1095328 if(!p_getcstr(&temp_meta.attribytes[q],f))
12911 return qe_invalid;
12912
2/4
✓ Branch 0 taken 1095328 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1095328 times.
✗ Branch 3 not taken.
1095328 if(!p_getwstr(&temp_meta.attribytes_help[q],f))
12913 return qe_invalid;
12914 1095328 }
12915
2/2
✓ Branch 0 taken 1095328 times.
✓ Branch 1 taken 136916 times.
1232244 for(auto q = 0; q < 8; ++q)
12916 {
12917
2/4
✓ Branch 0 taken 1095328 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1095328 times.
✗ Branch 3 not taken.
1095328 if(!p_getcstr(&temp_meta.attrishorts[q],f))
12918 return qe_invalid;
12919
2/4
✓ Branch 0 taken 1095328 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1095328 times.
✗ Branch 3 not taken.
1095328 if(!p_getwstr(&temp_meta.attrishorts_help[q],f))
12920 return qe_invalid;
12921 1095328 }
12922
2/2
✓ Branch 0 taken 2190656 times.
✓ Branch 1 taken 136916 times.
2327572 for(auto q = 0; q < 16; ++q)
12923 {
12924
2/4
✓ Branch 0 taken 2190656 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2190656 times.
✗ Branch 3 not taken.
2190656 if(!p_getcstr(&temp_meta.usrflags[q],f))
12925 return qe_invalid;
12926
2/4
✓ Branch 0 taken 2190656 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2190656 times.
✗ Branch 3 not taken.
2190656 if(!p_getwstr(&temp_meta.usrflags_help[q],f))
12927 return qe_invalid;
12928 2190656 }
12929 136916 }
12930
2/2
✓ Branch 0 taken 136916 times.
✓ Branch 1 taken 7194 times.
144110 if(zmeta_version > 3)
12931 {
12932
2/2
✓ Branch 0 taken 1095328 times.
✓ Branch 1 taken 136916 times.
1232244 for(auto q = 0; q < 8; ++q)
12933 {
12934
2/4
✓ Branch 0 taken 1095328 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1095328 times.
✗ Branch 3 not taken.
1095328 if(!p_getcstr(&temp_meta.initd[q],f))
12935 return qe_invalid;
12936
2/4
✓ Branch 0 taken 1095328 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1095328 times.
✗ Branch 3 not taken.
1095328 if(!p_getwstr(&temp_meta.initd_help[q],f))
12937 return qe_invalid;
12938 1095328 }
12939
2/2
✓ Branch 0 taken 1095328 times.
✓ Branch 1 taken 136916 times.
1232244 for(auto q = 0; q < 8; ++q)
12940 {
12941
2/4
✓ Branch 0 taken 1095328 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1095328 times.
✗ Branch 3 not taken.
1095328 if(!p_getc(&temp_meta.initd_type[q],f))
12942 return qe_invalid;
12943 1095328 }
12944 136916 }
12945 else
12946 {
12947
2/2
✓ Branch 0 taken 57552 times.
✓ Branch 1 taken 7194 times.
64746 for(auto q = 0; q < 8; ++q)
12948 {
12949
1/2
✓ Branch 0 taken 57552 times.
✗ Branch 1 not taken.
57552 temp_meta.initd[q] = temp_meta.run_idens[q];
12950 57552 }
12951 }
12952
12953
1/2
✓ Branch 0 taken 144110 times.
✗ Branch 1 not taken.
144110 (*script)->meta = temp_meta;
12954
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144110 times.
144110 }
12955
12956
1/2
✓ Branch 0 taken 262921 times.
✗ Branch 1 not taken.
262921 temp_script.clear();
12957
1/2
✓ Branch 0 taken 21879119 times.
✗ Branch 1 not taken.
21879119 for(int32_t j=0; j<num_commands; j++)
12958 {
12959
2/4
✓ Branch 0 taken 21879119 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 21879119 times.
✗ Branch 3 not taken.
21879119 if(!p_igetw(&(temp_script.command),f))
12960 {
12961 return qe_invalid;
12962 }
12963
12964
2/2
✓ Branch 0 taken 262921 times.
✓ Branch 1 taken 21616198 times.
21879119 if(temp_script.command == 0xFFFF)
12965 {
12966
1/2
✓ Branch 0 taken 262921 times.
✗ Branch 1 not taken.
262921 (*script)->zasm[j].clear();
12967 262921 break;
12968 }
12969 else
12970 {
12971
2/4
✓ Branch 0 taken 21616198 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 21616198 times.
✗ Branch 3 not taken.
21616198 if(!p_igetl(&(temp_script.arg1),f))
12972 {
12973 return qe_invalid;
12974 }
12975
12976
2/4
✓ Branch 0 taken 21616198 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 21616198 times.
✗ Branch 3 not taken.
21616198 if(!p_igetl(&(temp_script.arg2),f))
12977 {
12978 return qe_invalid;
12979 }
12980
12981
2/2
✓ Branch 0 taken 943577 times.
✓ Branch 1 taken 20672621 times.
21616198 if(s_version >= 21)
12982 {
12983 943577 uint32_t sz = 0;
12984
2/4
✓ Branch 0 taken 943577 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 943577 times.
✗ Branch 3 not taken.
943577 if(!p_igetl(&sz,f))
12985 {
12986 return qe_invalid;
12987 }
12988
2/2
✓ Branch 0 taken 3278 times.
✓ Branch 1 taken 940299 times.
943577 if(sz) //string found
12989 {
12990
1/2
✓ Branch 0 taken 3278 times.
✗ Branch 1 not taken.
3278 temp_script.strptr = new std::string();
12991 char dummy;
12992
2/2
✓ Branch 0 taken 234227 times.
✓ Branch 1 taken 3278 times.
237505 for(size_t q = 0; q < sz; ++q)
12993 {
12994
2/4
✓ Branch 0 taken 234227 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 234227 times.
✗ Branch 3 not taken.
234227 if(!p_getc(&dummy,f))
12995 {
12996 return qe_invalid;
12997 }
12998
1/2
✓ Branch 0 taken 234227 times.
✗ Branch 1 not taken.
234227 temp_script.strptr->push_back(dummy);
12999 234227 }
13000 3278 }
13001
2/4
✓ Branch 0 taken 943577 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 943577 times.
✗ Branch 3 not taken.
943577 if(!p_igetl(&sz,f))
13002 {
13003 return qe_invalid;
13004 }
13005
2/2
✓ Branch 0 taken 101 times.
✓ Branch 1 taken 943476 times.
943577 if(sz) //vector found
13006 {
13007
1/2
✓ Branch 0 taken 101 times.
✗ Branch 1 not taken.
101 temp_script.vecptr = new std::vector<int32_t>();
13008 int32_t dummy;
13009
2/2
✓ Branch 0 taken 1487 times.
✓ Branch 1 taken 101 times.
1588 for(size_t q = 0; q < sz; ++q)
13010 {
13011
2/4
✓ Branch 0 taken 1487 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1487 times.
✗ Branch 3 not taken.
1487 if(!p_igetl(&dummy,f))
13012 {
13013 return qe_invalid;
13014 }
13015
1/2
✓ Branch 0 taken 1487 times.
✗ Branch 1 not taken.
1487 temp_script.vecptr->push_back(dummy);
13016 1487 }
13017 101 }
13018 943577 }
13019
13020
1/2
✓ Branch 0 taken 21616198 times.
✗ Branch 1 not taken.
21616198 temp_script.give((*script)->zasm[j]);
13021 }
13022
1/2
✓ Branch 0 taken 21616198 times.
✗ Branch 1 not taken.
21616198 temp_script.clear();
13023 21616198 }
13024
13025
1/2
✓ Branch 0 taken 262921 times.
✗ Branch 1 not taken.
262921 (*script)->recalc_size();
13026
13027 262921 return 0;
13028 262921 }
13029
13030 extern SAMPLE customsfxdata[WAV_COUNT];
13031 extern uint8_t customsfxflag[WAV_COUNT>>3];
13032 extern int32_t sfxdat;
13033 extern DATAFILE *sfxdata;
13034 const char *old_sfx_string[Z35] =
13035 {
13036 "Arrow", "Sword beam", "Bomb blast", "Boomerang", "Subscreen cursor",
13037 "Shield is hit", "Item chime", "Roar (Dodongo, Gohma)", "Shutter", "Enemy dies",
13038 "Enemy is hit", "Low hearts warning", "Fire", "Ganon's fanfare", "Boss is hit", "Hammer",
13039 "Hookshot", "Message", "Player is hit", "Item fanfare", "Bomb placed", "Item pickup",
13040 "Refill", "Roar (Aquamentus, Gleeok, Ganon)", "Item pickup 2", "Ocean ambience",
13041 "Secret chime", "Player dies", "Stairs", "Sword", "Roar (Manhandla, Digdogger, Patra)",
13042 "Wand magic", "Whistle", "Zelda's fanfare", "Charging weapon", "Charging weapon 2",
13043 "Divine Fire", "Enemy falls from ceiling", "Divine Escape", "Fireball", "Tall Grass slashed",
13044 "Pound pounded", "Hover Boots", "Ice magic", "Jump", "Lens of Truth off", "Lens of Truth on",
13045 "Divine Protection shield", "Divine Protection 2", "Push block", "Rock", "Spell rocket down",
13046 "Spell rocket up", "Sword spin attack", "Splash", "Summon magic", "Sword tapping",
13047 "Sword tapping (secret)", "Whistle whirlwind", "Cane of Byrna orbit"
13048 };
13049 char *sfx_string[WAV_COUNT];
13050
13051 115 int32_t readsfx(PACKFILE *f, zquestheader *Header)
13052 {
13053 //these are here to bypass compiler warnings about unused arguments
13054 115 Header=Header;
13055
13056 int32_t dummy;
13057 115 word s_version=0, s_cversion=0;
13058 //int32_t ret;
13059 115 SAMPLE temp_sample = {};
13060 115 temp_sample.loop_start=0;
13061 115 temp_sample.loop_end=0;
13062 115 temp_sample.param=0;
13063
13064 //section version info
13065
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 115 times.
115 if(!p_igetw(&s_version,f))
13066 {
13067 return qe_invalid;
13068 }
13069
13070 115 FFCore.quest_format[vSFX] = s_version;
13071
13072 //al_trace("SFX version %d\n", s_version);
13073
1/2
✓ Branch 0 taken 115 times.
✗ Branch 1 not taken.
115 if(!p_igetw(&s_cversion,f))
13074 {
13075 return qe_invalid;
13076 }
13077
13078 //section size
13079
1/2
✓ Branch 0 taken 115 times.
✗ Branch 1 not taken.
115 if(!p_igetl(&dummy,f))
13080 {
13081 return qe_invalid;
13082 }
13083
13084 /* HIGHLY UNORTHODOX UPDATING THING, by L
13085 * This fixes quests made before revision 411 (such as the 'Lost Isle Build'),
13086 * where the meaning of GOTOLESS changed. It also coincided with V_SFX
13087 * changing from 1 to 2.
13088 */
13089
1/2
✓ Branch 0 taken 115 times.
✗ Branch 1 not taken.
115 if(s_version < 2)
13090 set_qr(qr_GOTOLESSNOTEQUAL,1);
13091
13092 /* End highly unorthodox updating thing */
13093
13094 115 int32_t wavcount = WAV_COUNT;
13095
13096
1/2
✓ Branch 0 taken 115 times.
✗ Branch 1 not taken.
115 if(s_version < 6)
13097 wavcount = 128;
13098
13099 uint8_t tempflag[WAV_COUNT>>3];
13100
13101
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 115 times.
115 if(s_version < 4)
13102 {
13103 memset(tempflag, 0xFF, WAV_COUNT>>3);
13104 }
13105 else
13106 {
13107
1/2
✓ Branch 0 taken 115 times.
✗ Branch 1 not taken.
115 if(s_version < 6)
13108 memset(tempflag, 0, WAV_COUNT>>3);
13109
13110
2/2
✓ Branch 0 taken 3680 times.
✓ Branch 1 taken 115 times.
3795 for(int32_t i=0; i<(wavcount>>3); i++)
13111 {
13112 3680 p_getc(&tempflag[i], f);
13113 3680 }
13114
13115 }
13116
13117
1/2
✓ Branch 0 taken 115 times.
✗ Branch 1 not taken.
115 if(s_version>4)
13118 {
13119
2/2
✓ Branch 0 taken 29325 times.
✓ Branch 1 taken 115 times.
29440 for(int32_t i=1; i<WAV_COUNT; i++)
13120 {
13121 29325 sprintf(sfx_string[i],"s%03d",i);
13122
13123
2/2
✓ Branch 0 taken 22425 times.
✓ Branch 1 taken 6900 times.
29325 if((i<Z35))
13124 6900 strcpy(sfx_string[i], old_sfx_string[i-1]);
13125
13126
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29325 times.
29325 if(i>=wavcount)
13127 continue;
13128
2/2
✓ Branch 0 taken 3218 times.
✓ Branch 1 taken 26107 times.
29325 if(get_bit(tempflag, i-1))
13129 {
13130 char tempname[36];
13131
13132
1/2
✓ Branch 0 taken 3218 times.
✗ Branch 1 not taken.
3218 if(!pfread(tempname, 36, f))
13133 {
13134 return qe_invalid;
13135 }
13136
13137 3218 sfx_string[i][0] = '\0';
13138 3218 strncat(sfx_string[i], tempname, 36 - 1);
13139 3218 }
13140 else
13141 {
13142 26107 sprintf(sfx_string[i],"s%03d",i);
13143
13144
2/2
✓ Branch 0 taken 21529 times.
✓ Branch 1 taken 4578 times.
26107 if(i<Z35)
13145 4578 strcpy(sfx_string[i], old_sfx_string[i-1]);
13146 26107 sfx_string[i][35] = 0; //Force NULL Termination
13147 }
13148 29325 }
13149 115 }
13150 else
13151 {
13152 for(int32_t i=1; i<WAV_COUNT; i++)
13153 {
13154 sprintf(sfx_string[i],"s%03d",i);
13155
13156 if(i<Z35)
13157 strcpy(sfx_string[i], old_sfx_string[i-1]);
13158 }
13159 }
13160
13161 //finally... section data
13162
2/2
✓ Branch 0 taken 29325 times.
✓ Branch 1 taken 115 times.
29440 for(int32_t i=1; i<wavcount; i++)
13163 {
13164
2/2
✓ Branch 0 taken 3218 times.
✓ Branch 1 taken 26107 times.
29325 if(get_bit(tempflag, i-1))
13165 {
13166
13167
1/2
✓ Branch 0 taken 3218 times.
✗ Branch 1 not taken.
3218 if(!p_igetl(&dummy,f))
13168 {
13169 return qe_invalid;
13170 }
13171
13172 3218 (temp_sample.bits) = dummy;
13173
13174
1/2
✓ Branch 0 taken 3218 times.
✗ Branch 1 not taken.
3218 if(!p_igetl(&dummy,f))
13175 {
13176 return qe_invalid;
13177 }
13178
13179 3218 (temp_sample.stereo) = dummy;
13180
13181
1/2
✓ Branch 0 taken 3218 times.
✗ Branch 1 not taken.
3218 if(!p_igetl(&dummy,f))
13182 {
13183 return qe_invalid;
13184 }
13185
13186 3218 (temp_sample.freq) = dummy;
13187
13188
1/2
✓ Branch 0 taken 3218 times.
✗ Branch 1 not taken.
3218 if(!p_igetl(&dummy,f))
13189 {
13190 return qe_invalid;
13191 }
13192
13193 3218 (temp_sample.priority) = dummy;
13194
13195
1/2
✓ Branch 0 taken 3218 times.
✗ Branch 1 not taken.
3218 if(!p_igetl(&(temp_sample.len),f))
13196 {
13197 return qe_invalid;
13198 }
13199
13200
1/2
✓ Branch 0 taken 3218 times.
✗ Branch 1 not taken.
3218 if(!p_igetl(&(temp_sample.loop_start),f))
13201 {
13202 return qe_invalid;
13203 }
13204
13205
1/2
✓ Branch 0 taken 3218 times.
✗ Branch 1 not taken.
3218 if(!p_igetl(&(temp_sample.loop_end),f))
13206 {
13207 return qe_invalid;
13208 }
13209
13210
1/2
✓ Branch 0 taken 3218 times.
✗ Branch 1 not taken.
3218 if(!p_igetl(&(temp_sample.param),f))
13211 {
13212 return qe_invalid;
13213 }
13214
13215 // al_trace("F%i: L%i\n",i,temp_sample.len);
13216 // temp_sample.data = new byte[(temp_sample.bits==8?1:2)*temp_sample.len];
13217 3218 auto len = (temp_sample.bits==8?1:2)*(temp_sample.stereo==0?1:2)*temp_sample.len;
13218
2/4
✓ Branch 0 taken 3218 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 3218 times.
3218 if (len < 0 || len > 10000000)
13219 {
13220 return qe_invalid;
13221 }
13222 3218 temp_sample.data = calloc(len,1);
13223
13224
1/2
✓ Branch 0 taken 3218 times.
✗ Branch 1 not taken.
3218 if(s_version < 3)
13225 len = (temp_sample.bits==8?1:2)*temp_sample.len;
13226
13227 //old-style, non-portable loading (Bad Allegro! Bad!!) -DD
13228
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3218 times.
3218 if(s_version < 2)
13229 {
13230 if(!pfread(temp_sample.data, len,f))
13231 {
13232 return qe_invalid;
13233 }
13234 }
13235 else
13236 {
13237 //re-endianfy the data
13238 3218 int32_t wordstoread = len / sizeof(word);
13239
13240
2/2
✓ Branch 0 taken 92797130 times.
✓ Branch 1 taken 3218 times.
92800348 for(int32_t j=0; j<wordstoread; j++)
13241 {
13242 word temp;
13243
13244
1/2
✓ Branch 0 taken 92797130 times.
✗ Branch 1 not taken.
92797130 if(!p_igetw(&temp, f))
13245 {
13246 return qe_invalid;
13247 }
13248
13249 92797130 ((word *)temp_sample.data)[j] = temp;
13250 92797130 }
13251 }
13252 3218 }
13253
2/2
✓ Branch 0 taken 4578 times.
✓ Branch 1 taken 21529 times.
26107 else if(i < Z35)
13254 {
13255 4578 SAMPLE* datsamp = (SAMPLE*)(sfxdata[i].dat);
13256 4578 memcpy(&temp_sample, datsamp, sizeof(SAMPLE));
13257 4578 set_bit(tempflag, i-1, 1);
13258 4578 int32_t len = (temp_sample.bits==8?1:2)*(temp_sample.stereo==0?1:2)*temp_sample.len;
13259 4578 temp_sample.data = calloc(len,1);
13260 4578 memcpy(temp_sample.data, datsamp->data, len);
13261 4578 }
13262 21529 else continue;
13263
13264
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7796 times.
7796 if(customsfxdata[i].data!=NULL)
13265 {
13266 // delete [] customsfxdata[i].data;
13267 7796 free(customsfxdata[i].data);
13268 7796 }
13269
13270 // customsfxdata[i].data = new byte[(temp_sample.bits==8?1:2)*temp_sample.len];
13271 7796 int32_t len2 = (temp_sample.bits==8?1:2)*(temp_sample.stereo==0?1:2)*temp_sample.len;
13272 7796 customsfxdata[i].data = calloc(len2,1);
13273 7796 customsfxdata[i].bits = temp_sample.bits;
13274 7796 customsfxdata[i].stereo = temp_sample.stereo;
13275 7796 customsfxdata[i].freq = temp_sample.freq;
13276 7796 customsfxdata[i].priority = temp_sample.priority;
13277 7796 customsfxdata[i].len = temp_sample.len;
13278 7796 customsfxdata[i].loop_start = temp_sample.loop_start;
13279 7796 customsfxdata[i].loop_end = temp_sample.loop_end;
13280 7796 customsfxdata[i].param = temp_sample.param;
13281 7796 int32_t cpylen = len2;
13282
13283
1/2
✓ Branch 0 taken 7796 times.
✗ Branch 1 not taken.
7796 if(s_version<3)
13284 {
13285 cpylen = (temp_sample.bits==8?1:2)*temp_sample.len;
13286 al_trace("WARNING: Quest SFX %d is in stereo, and may be corrupt.\n",i);
13287 }
13288
13289 7796 memcpy(customsfxdata[i].data,temp_sample.data,cpylen);
13290
13291 7796 free(temp_sample.data);
13292 7796 }
13293
13294 115 memcpy(customsfxflag, tempflag, WAV_COUNT>>3);
13295
13296 115 sfxdat=0;
13297 115 return 0;
13298 115 }
13299
13300 131 void setupsfx()
13301 {
13302
2/2
✓ Branch 0 taken 33405 times.
✓ Branch 1 taken 131 times.
33536 for(int32_t i=1; i<WAV_COUNT; i++)
13303 {
13304 33405 sprintf(sfx_string[i],"s%03d",i);
13305
13306
2/2
✓ Branch 0 taken 25545 times.
✓ Branch 1 taken 7860 times.
33405 if(i<Z35)
13307 {
13308 7860 strcpy(sfx_string[i], old_sfx_string[i-1]);
13309 7860 }
13310
13311 33405 memset(customsfxflag, 0, WAV_COUNT>>3);
13312
13313 33405 int32_t j=i;
13314
13315
2/2
✓ Branch 0 taken 7991 times.
✓ Branch 1 taken 25414 times.
33405 if(i>Z35)
13316 {
13317 25414 i=Z35;
13318 25414 }
13319
13320 33405 SAMPLE *temp_sample = (SAMPLE *)sfxdata[i].dat;
13321
13322
2/2
✓ Branch 0 taken 29835 times.
✓ Branch 1 taken 3570 times.
33405 if(customsfxdata[j].data!=NULL)
13323 {
13324 // delete [] customsfxdata[j].data;
13325 3570 free(customsfxdata[j].data);
13326 3570 }
13327
13328 // customsfxdata[j].data = new byte[(temp_sample->bits==8?1:2)*temp_sample->len];
13329 33405 customsfxdata[j].data = calloc((temp_sample->bits==8?1:2)*(temp_sample->stereo == 0 ? 1 : 2)*temp_sample->len,1);
13330 33405 customsfxdata[j].bits = temp_sample->bits;
13331 33405 customsfxdata[j].stereo = temp_sample->stereo;
13332 33405 customsfxdata[j].freq = temp_sample->freq;
13333 33405 customsfxdata[j].priority = temp_sample->priority;
13334 33405 customsfxdata[j].len = temp_sample->len;
13335 33405 customsfxdata[j].loop_start = temp_sample->loop_start;
13336 33405 customsfxdata[j].loop_end = temp_sample->loop_end;
13337 33405 customsfxdata[j].param = temp_sample->param;
13338 33405 memcpy(customsfxdata[j].data, (temp_sample->data), (temp_sample->bits==8?1:2)*(temp_sample->stereo==0 ? 1 : 2)*temp_sample->len);
13339 33405 i=j;
13340 33405 }
13341 131 }
13342
13343 extern char *guy_string[eMAXGUYS];
13344 extern const char *old_guy_string[OLDMAXGUYS];
13345
13346 131 int32_t readguys(PACKFILE *f, zquestheader *Header)
13347 {
13348
2/2
✓ Branch 0 taken 127 times.
✓ Branch 1 taken 4 times.
131 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_guys);
13349
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 131 times.
131 if (should_skip) return 0;
13350
13351 dword dummy;
13352 word guy_cversion;
13353 131 word guyversion=0;
13354
13355
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 127 times.
131 if(Header->zelda_version >= 0x193)
13356 {
13357 //section version info
13358
1/2
✓ Branch 0 taken 127 times.
✗ Branch 1 not taken.
127 if(!p_igetw(&guyversion,f))
13359 {
13360 return qe_invalid;
13361 }
13362
13363 127 FFCore.quest_format[vGuys] = guyversion;
13364
13365 //al_trace("Guys version %d\n", guyversion);
13366
1/2
✓ Branch 0 taken 127 times.
✗ Branch 1 not taken.
127 if(!p_igetw(&guy_cversion,f))
13367 {
13368 return qe_invalid;
13369 }
13370 127 al_trace("Guy CVersion is: %d\n", guy_cversion);
13371 //section size
13372
1/2
✓ Branch 0 taken 127 times.
✗ Branch 1 not taken.
127 if(!p_igetl(&dummy,f))
13373 {
13374 return qe_invalid;
13375 }
13376 127 }
13377
13378
2/2
✓ Branch 0 taken 115 times.
✓ Branch 1 taken 16 times.
131 if(guyversion > 3)
13379 {
13380
2/2
✓ Branch 0 taken 58880 times.
✓ Branch 1 taken 115 times.
58995 for(int32_t i=0; i<MAXGUYS; i++)
13381 {
13382 char tempname[64];
13383
13384 // rev. 1511 : guyversion = 23. upped to 512 editable enemies. -Gleeok
13385 // if guyversion < 23 then there is only 256 enemies in the packfile, so default the rest.
13386
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 58880 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
58880 if(guyversion < 23 && i >= OLDBETAMAXGUYS)
13387 {
13388 memset(tempname, 0, sizeof(char)*64);
13389 sprintf(tempname, "e%03d", i);
13390 strcpy(guy_string[i], tempname);
13391
13392 continue;
13393 }
13394
13395
1/2
✓ Branch 0 taken 58880 times.
✗ Branch 1 not taken.
58880 if(!pfread(tempname, 64, f))
13396 {
13397 return qe_invalid;
13398 }
13399
13400 // Don't retain names of uneditable enemy entries!
13401 // for version upgrade to 2.5
13402
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 58880 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
58880 if(guyversion < 23 && i >= 177)
13403 {
13404 // some of the older builds have names such as 'zz123',
13405 // (this order gets messed up with some eXXX and some zzXXX)
13406 // so let's update to the newer naming convection. -Gleeok
13407 char tmpbuf[64];
13408 memset(tmpbuf, 0, sizeof(char)*64);
13409 sprintf(tmpbuf, "zz%03d", i);
13410
13411 if(memcmp(tempname, tmpbuf, size_t(5)) == 0)
13412 {
13413 memset(tempname, 0, sizeof(char)*64);
13414 sprintf(tempname, "e%03d", i);
13415 }
13416 }
13417
13418
6/6
✓ Branch 0 taken 20355 times.
✓ Branch 1 taken 38525 times.
✓ Branch 2 taken 19320 times.
✓ Branch 3 taken 1035 times.
✓ Branch 4 taken 16281 times.
✓ Branch 5 taken 3039 times.
58880 if(i >= OLDMAXGUYS || strlen(tempname)<1 || tempname[strlen(tempname)-1]!=' ')
13419 {
13420 55841 guy_string[i][0] = '\0';
13421 55841 strncat(guy_string[i], tempname, 64 - 1);
13422 55841 }
13423 else
13424 {
13425 3039 strcpy(guy_string[i],old_guy_string[i]);
13426 }
13427 58880 }
13428 115 }
13429 else
13430 {
13431
2/2
✓ Branch 0 taken 8192 times.
✓ Branch 1 taken 16 times.
8208 for(int32_t i=0; i<eMAXGUYS; i++)
13432 {
13433 8192 sprintf(guy_string[i],"zz%03d",i);
13434 8192 }
13435
13436
2/2
✓ Branch 0 taken 2832 times.
✓ Branch 1 taken 16 times.
2848 for(int32_t i=0; i<OLDMAXGUYS; i++)
13437 {
13438 2832 strcpy(guy_string[i],old_guy_string[i]);
13439 2832 }
13440 }
13441
13442
13443 //finally... section data
13444 131 init_guys(guyversion); //using default data for now...
13445
13446 // Goriya guy fix
13447
3/6
✓ Branch 0 taken 115 times.
✓ Branch 1 taken 16 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 115 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
131 if((Header->zelda_version < 0x211)||((Header->zelda_version == 0x211)&&(Header->build<7)))
13448 {
13449
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 12 times.
16 if(get_qr(qr_NEWENEMYTILES))
13450 {
13451 12 guysbuf[gGORIYA].tile=130;
13452 12 guysbuf[gGORIYA].e_tile=130;
13453 12 }
13454 16 }
13455
13456
2/2
✓ Branch 0 taken 127 times.
✓ Branch 1 taken 4 times.
131 if(Header->zelda_version < 0x193)
13457 {
13458
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(get_bit(deprecated_rules,46))
13459 {
13460 guysbuf[eDODONGO].cset=14;
13461 guysbuf[eDODONGO].bosspal=spDIG;
13462 }
13463 4 }
13464 // Not sure when this first changed, but it's necessary for 2.10, at least
13465 // @TODO: @BUG:1.92 - 1.84? Figure this out exactly for the final 2.50 release.
13466 //2.10 Fixes
13467
3/6
✓ Branch 0 taken 115 times.
✓ Branch 1 taken 16 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 115 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
131 if((Header->zelda_version < 0x211)||((Header->zelda_version == 0x211)&&(Header->build<18)))
13468 {
13469 16 guysbuf[eWWIZ].editorflags |= ENEMY_FLAG5;
13470 16 guysbuf[eMOLDORM].editorflags |= ENEMY_FLAG6;
13471 16 guysbuf[eMANHAN].editorflags |= ENEMY_FLAG6;
13472 16 guysbuf[eCENT1].misc3 = 1;
13473 16 guysbuf[eCENT2].misc3 = 1;
13474 16 }
13475
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 131 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
131 if((Header->zelda_version <= 0x255) || (Header->zelda_version == 0x255 && Header->build < 47) )
13476 {
13477 131 guysbuf[eWPOLSV].defense[edefWhistle] = ed1HKO;
13478 131 }
13479
2/2
✓ Branch 0 taken 115 times.
✓ Branch 1 taken 16 times.
131 if(Header->zelda_version <= 0x210)
13480 {
13481 16 guysbuf[eGLEEOK1F].misc6 = 16;
13482 16 guysbuf[eGLEEOK2F].misc6 = 16;
13483 16 guysbuf[eGLEEOK3F].misc6 = 16;
13484 16 guysbuf[eGLEEOK4F].misc6 = 16;
13485
13486 16 guysbuf[eWIZ1].misc4 = 1; //only set the enemy that needs backward compat, not all of them.
13487 16 guysbuf[eBATROBE].misc4 = 1;
13488 //guysbuf[eSUMMONER].misc4 = 1;
13489 16 guysbuf[eWWIZ].misc4 = 1;
13490 16 guysbuf[eDODONGO].deadsfx = 15; //In 2.10 and earlier, Dodongos used this as their death sound.
13491 16 guysbuf[eDODONGOBS].deadsfx = 15; //In 2.10 and earlier, Dodongos used this as their death sound.
13492 16 }
13493
2/2
✓ Branch 0 taken 127 times.
✓ Branch 1 taken 4 times.
131 if(Header->zelda_version == 0x190)
13494 {
13495 4 al_trace("Setting Tribble Properties for Version: %x", Header->zelda_version);
13496 4 guysbuf[eKEESETRIB].misc3 = eVIRE; //1.90 and earlier, keese and gel tribbles grew up into
13497 4 guysbuf[eGELTRIB].misc3 = eZOL; //normal vires, and zols -Z (16th January, 2019 )
13498 4 }
13499
13500 // The versions here may not be correct
13501 // zelda_version>=0x211 handled at guyversion<24
13502
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 127 times.
131 if(Header->zelda_version <= 0x190)
13503 {
13504 4 guysbuf[eCENT1].misc3 = 0;
13505 4 guysbuf[eCENT2].misc3 = 0;
13506 4 guysbuf[eMOLDORM].misc2 = 0;
13507 //guysbuf[eKEESETRIB].misc3 = eVIRE; //1.90 and earlier, keese and gel tribbles grew up into
13508 //guysbuf[eGELTRIB].misc3 = eZOL; //normal vires, and zols -Z (16th January, 2019 )
13509 4 }
13510
2/2
✓ Branch 0 taken 115 times.
✓ Branch 1 taken 12 times.
127 else if(Header->zelda_version <= 0x210)
13511 {
13512 12 guysbuf[eCENT1].misc3 = 1;
13513 12 guysbuf[eCENT2].misc3 = 1;
13514 12 guysbuf[eMOLDORM].misc2 = 0;
13515 12 }
13516
13517
2/2
✓ Branch 0 taken 115 times.
✓ Branch 1 taken 16 times.
131 if ( Header->zelda_version < 0x211 ) //Default rest rates for phantom ghinis, peahats and keese in < 2.50 quests
13518 {
13519 16 guysbuf[eKEESE1].misc16 = 120;
13520 16 guysbuf[eKEESE2].misc16 = 120;
13521 16 guysbuf[eKEESE3].misc16 = 120;
13522 16 guysbuf[eKEESETRIB].misc16 = 120;
13523 16 guysbuf[eKEESE1].misc17 = 16;
13524 16 guysbuf[eKEESE2].misc17 = 16;
13525 16 guysbuf[eKEESE3].misc17 = 16;
13526 16 guysbuf[eKEESETRIB].misc17 = 16;
13527
13528 16 guysbuf[ePEAHAT].misc16 = 80;
13529 16 guysbuf[ePEAHAT].misc17 = 16;
13530
13531 16 guysbuf[eGHINI2].misc16 = 120;
13532 16 guysbuf[eGHINI2].misc17 = 10;
13533
13534
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if (replay_version_check(20))
13535 {
13536 guysbuf[eGHINI2].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13537 guysbuf[eMOLDORM].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13538 guysbuf[eKEESETRIB].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13539 guysbuf[eKEESE3].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13540 guysbuf[eKEESE2].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13541 guysbuf[eKEESE1].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13542 guysbuf[eTEK1].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13543 guysbuf[eTEK2].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13544 guysbuf[ePEAHAT].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13545 guysbuf[eROCK].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13546 guysbuf[eTRAP].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13547 guysbuf[eWALLM].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13548 guysbuf[ePOLSV].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13549 guysbuf[eMANHAN].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13550 guysbuf[eGLEEOK1].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13551 guysbuf[eGLEEOK2].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13552 guysbuf[eGLEEOK3].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13553 guysbuf[eGLEEOK4].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13554 guysbuf[eDIG1].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13555 guysbuf[eDIG3].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13556 guysbuf[eDIGPUP1].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13557 guysbuf[eDIGPUP2].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13558 guysbuf[eDIGPUP3].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13559 guysbuf[eDIGPUP4].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13560 guysbuf[eRAQUAM].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13561 guysbuf[eITEMFAIRY].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13562 guysbuf[eFIRE].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13563 guysbuf[eMANHAN2].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13564 guysbuf[eTRAP_H].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13565 guysbuf[eTRAP_V].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13566 guysbuf[eTRAP_LR].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13567 guysbuf[eTRAP_UD].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13568 guysbuf[ePATRA1].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13569 guysbuf[ePATRA2].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13570 guysbuf[ePATRABS].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13571 guysbuf[eBAT].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13572 guysbuf[eGLEEOK1F].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13573 guysbuf[eGLEEOK2F].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13574 guysbuf[eGLEEOK3F].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13575 guysbuf[eGLEEOK4F].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13576 guysbuf[eTRIGGER].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13577 guysbuf[ePATRAL2].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13578 guysbuf[ePATRAL3].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13579 guysbuf[eGOHMA1].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13580 guysbuf[eGOHMA2].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13581 guysbuf[eGOHMA3].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13582 guysbuf[eGOHMA4].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13583 guysbuf[eMPOLSV].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13584 guysbuf[eWPOLSV].moveflags |= (FLAG_CAN_WATERWALK|FLAG_CAN_PITWALK);
13585 }
13586 16 }
13587
13588
13589
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 115 times.
131 if(guyversion<=2)
13590 {
13591 16 return readherosprites2(f, guyversion==2?0:-1, 0);
13592 }
13593
13594
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 115 times.
115 if(guyversion > 3)
13595 {
13596 guydata tempguy;
13597
13598
2/2
✓ Branch 0 taken 58880 times.
✓ Branch 1 taken 115 times.
58995 for(int32_t i=0; i<MAXGUYS; i++)
13599 {
13600
1/2
✓ Branch 0 taken 58880 times.
✗ Branch 1 not taken.
58880 if(guyversion < 23) // May 2012 : 512 max enemies
13601 {
13602 if(i >= OLDBETAMAXGUYS)
13603 {
13604 memset(&guysbuf[i], 0, sizeof(guydata));
13605 continue;
13606 }
13607 }
13608
13609 58880 memset(&tempguy, 0, sizeof(guydata));
13610
13611
1/2
✓ Branch 0 taken 58880 times.
✗ Branch 1 not taken.
58880 if(!p_igetl(&(tempguy.flags),f))
13612 {
13613 return qe_invalid;
13614 }
13615
13616
1/2
✓ Branch 0 taken 58880 times.
✗ Branch 1 not taken.
58880 if(!p_igetl(&(tempguy.flags2),f))
13617 {
13618 return qe_invalid;
13619 }
13620
13621
2/2
✓ Branch 0 taken 19456 times.
✓ Branch 1 taken 39424 times.
58880 if ( guyversion >= 36 ) //expanded tiles
13622 {
13623
1/2
✓ Branch 0 taken 19456 times.
✗ Branch 1 not taken.
19456 if(!p_igetl(&(tempguy.tile),f))
13624 {
13625 return qe_invalid;
13626 }
13627 19456 }
13628 else
13629 {
13630
1/2
✓ Branch 0 taken 39424 times.
✗ Branch 1 not taken.
39424 if(!p_igetw(&(tempguy.tile),f))
13631 {
13632 return qe_invalid;
13633 }
13634 }
13635
1/2
✓ Branch 0 taken 58880 times.
✗ Branch 1 not taken.
58880 if(!p_getc(&(tempguy.width),f))
13636 {
13637 return qe_invalid;
13638 }
13639
13640
1/2
✓ Branch 0 taken 58880 times.
✗ Branch 1 not taken.
58880 if(!p_getc(&(tempguy.height),f))
13641 {
13642 return qe_invalid;
13643 }
13644
13645
2/2
✓ Branch 0 taken 19456 times.
✓ Branch 1 taken 39424 times.
58880 if ( guyversion >= 36 ) //expanded tiles
13646 {
13647
1/2
✓ Branch 0 taken 19456 times.
✗ Branch 1 not taken.
19456 if(!p_igetl(&(tempguy.s_tile),f))
13648 {
13649 return qe_invalid;
13650 }
13651 19456 }
13652 else
13653 {
13654
1/2
✓ Branch 0 taken 39424 times.
✗ Branch 1 not taken.
39424 if(!p_igetw(&(tempguy.s_tile),f))
13655 {
13656 return qe_invalid;
13657 }
13658 }
13659
13660
1/2
✓ Branch 0 taken 58880 times.
✗ Branch 1 not taken.
58880 if(!p_getc(&(tempguy.s_width),f))
13661 {
13662 return qe_invalid;
13663 }
13664
13665
1/2
✓ Branch 0 taken 58880 times.
✗ Branch 1 not taken.
58880 if(!p_getc(&(tempguy.s_height),f))
13666 {
13667 return qe_invalid;
13668 }
13669
13670
2/2
✓ Branch 0 taken 19456 times.
✓ Branch 1 taken 39424 times.
58880 if ( guyversion >= 36 ) //expanded tiles
13671 {
13672
1/2
✓ Branch 0 taken 19456 times.
✗ Branch 1 not taken.
19456 if(!p_igetl(&(tempguy.e_tile),f))
13673 {
13674 return qe_invalid;
13675 }
13676 19456 }
13677 else
13678 {
13679
1/2
✓ Branch 0 taken 39424 times.
✗ Branch 1 not taken.
39424 if(!p_igetw(&(tempguy.e_tile),f))
13680 {
13681 return qe_invalid;
13682 }
13683 }
13684
13685
1/2
✓ Branch 0 taken 58880 times.
✗ Branch 1 not taken.
58880 if(!p_getc(&(tempguy.e_width),f))
13686 {
13687 return qe_invalid;
13688 }
13689
13690
1/2
✓ Branch 0 taken 58880 times.
✗ Branch 1 not taken.
58880 if(!p_getc(&(tempguy.e_height),f))
13691 {
13692 return qe_invalid;
13693 }
13694
13695
1/2
✓ Branch 0 taken 58880 times.
✗ Branch 1 not taken.
58880 if(!p_igetw(&(tempguy.hp),f))
13696 {
13697 return qe_invalid;
13698 }
13699
13700
1/2
✓ Branch 0 taken 58880 times.
✗ Branch 1 not taken.
58880 if(!p_igetw(&(tempguy.family),f))
13701 {
13702 return qe_invalid;
13703 }
13704
13705
1/12
✗ Branch 0 not taken.
✓ Branch 1 taken 58880 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
58880 if(guyversion < 9 && (i==eDKNUT1 || i==eDKNUT2 || i==eDKNUT3 || i==eDKNUT4 || i==eDKNUT5)) // Whoops, forgot about Darknuts...
13706 {
13707 if(get_qr(qr_NEWENEMYTILES))
13708 {
13709 tempguy.s_tile=tempguy.e_tile+120;
13710 tempguy.s_width=tempguy.e_width;
13711 tempguy.s_height=tempguy.e_height;
13712 }
13713 else tempguy.s_tile=860;
13714 }
13715
13716
1/2
✓ Branch 0 taken 58880 times.
✗ Branch 1 not taken.
58880 if(!p_igetw(&(tempguy.cset),f))
13717 {
13718 return qe_invalid;
13719 }
13720
13721
1/2
✓ Branch 0 taken 58880 times.
✗ Branch 1 not taken.
58880 if(!p_igetw(&(tempguy.anim),f))
13722 {
13723 return qe_invalid;
13724 }
13725
13726
1/2
✓ Branch 0 taken 58880 times.
✗ Branch 1 not taken.
58880 if(!p_igetw(&(tempguy.e_anim),f))
13727 {
13728 return qe_invalid;
13729 }
13730
13731
1/2
✓ Branch 0 taken 58880 times.
✗ Branch 1 not taken.
58880 if(!p_igetw(&(tempguy.frate),f))
13732 {
13733 return qe_invalid;
13734 }
13735
13736
1/2
✓ Branch 0 taken 58880 times.
✗ Branch 1 not taken.
58880 if(!p_igetw(&(tempguy.e_frate),f))
13737 {
13738 return qe_invalid;
13739 }
13740
13741
1/2
✓ Branch 0 taken 58880 times.
✗ Branch 1 not taken.
58880 if(guyversion < 13) // April 2009
13742 {
13743 if(get_bit(deprecated_rules, qr_SLOWENEMYANIM_DEP))
13744 {
13745 tempguy.frate *= 2;
13746 tempguy.e_frate *= 2;
13747 }
13748 }
13749
13750
1/2
✓ Branch 0 taken 58880 times.
✗ Branch 1 not taken.
58880 if(guyversion < 14) // May 1 2009
13751 {
13752 if(tempguy.anim==a2FRMSLOW)
13753 {
13754 tempguy.anim=a2FRM;
13755 tempguy.frate *= 2;
13756 }
13757
13758 if(tempguy.e_anim==a2FRMSLOW)
13759 {
13760 tempguy.e_anim=a2FRM;
13761 tempguy.e_frate *= 2;
13762 }
13763
13764 if(tempguy.anim==aFLIPSLOW)
13765 {
13766 tempguy.anim=aFLIP;
13767 tempguy.frate *= 2;
13768 }
13769
13770 if(tempguy.e_anim==aFLIPSLOW)
13771 {
13772 tempguy.e_anim=aFLIP;
13773 tempguy.e_frate *= 2;
13774 }
13775
13776 if(tempguy.anim == aNEWDWALK) tempguy.anim = a4FRM4DIR;
13777
13778 if(tempguy.e_anim == aNEWDWALK) tempguy.e_anim = a4FRM4DIR;
13779
13780 if(tempguy.anim == aNEWPOLV || tempguy.anim == a4FRM3TRAP)
13781 {
13782 tempguy.anim=a4FRM4DIR;
13783 tempguy.s_tile=(get_qr(qr_NEWENEMYTILES) ? tempguy.e_tile : tempguy.tile)+20;
13784 }
13785
13786 if(tempguy.e_anim == aNEWPOLV || tempguy.e_anim == a4FRM3TRAP)
13787 {
13788 tempguy.e_anim=a4FRM4DIR;
13789 tempguy.s_tile=(get_qr(qr_NEWENEMYTILES) ? tempguy.e_tile : tempguy.tile)+20;
13790 }
13791 }
13792
13793
1/2
✓ Branch 0 taken 58880 times.
✗ Branch 1 not taken.
58880 if(!p_igetw(&(tempguy.dp),f))
13794 {
13795 return qe_invalid;
13796 }
13797
13798 //correction for guy fire
13799
1/2
✓ Branch 0 taken 58880 times.
✗ Branch 1 not taken.
58880 if(guyversion < 6)
13800 {
13801 if(i == gFIRE)
13802 tempguy.dp = 2;
13803 }
13804
13805
1/2
✓ Branch 0 taken 58880 times.
✗ Branch 1 not taken.
58880 if(!p_igetw(&(tempguy.wdp),f))
13806 {
13807 return qe_invalid;
13808 }
13809
13810
1/2
✓ Branch 0 taken 58880 times.
✗ Branch 1 not taken.
58880 if(!p_igetw(&(tempguy.weapon),f))
13811 {
13812 return qe_invalid;
13813 }
13814
13815 //correction for bosses using triple, "rising" fireballs
13816
1/2
✓ Branch 0 taken 58880 times.
✗ Branch 1 not taken.
58880 if(guyversion < 5)
13817 {
13818 if(i == eLAQUAM || i == eRAQUAM || i == eGOHMA1 || i == eGOHMA2 ||
13819 i == eGOHMA3 || i == eGOHMA4)
13820 {
13821 if(tempguy.weapon == ewFireball)
13822 tempguy.weapon = ewFireball2;
13823 }
13824 }
13825
13826
1/2
✓ Branch 0 taken 58880 times.
✗ Branch 1 not taken.
58880 if(!p_igetw(&(tempguy.rate),f))
13827 {
13828 return qe_invalid;
13829 }
13830
13831
1/2
✓ Branch 0 taken 58880 times.
✗ Branch 1 not taken.
58880 if(!p_igetw(&(tempguy.hrate),f))
13832 {
13833 return qe_invalid;
13834 }
13835
13836
1/2
✓ Branch 0 taken 58880 times.
✗ Branch 1 not taken.
58880 if(!p_igetw(&(tempguy.step),f))
13837 {
13838 return qe_invalid;
13839 }
13840
13841 // HIGHLY UNORTHODOX UPDATING THING, part 2
13842
3/4
✓ Branch 0 taken 1536 times.
✓ Branch 1 taken 57344 times.
✓ Branch 2 taken 1536 times.
✗ Branch 3 not taken.
58880 if(fixpolsvoice && tempguy.family==eePOLSV)
13843 {
13844 tempguy.step /= 2;
13845 }
13846
13847
1/2
✓ Branch 0 taken 58880 times.
✗ Branch 1 not taken.
58880 if(!p_igetw(&(tempguy.homing),f))
13848 {
13849 return qe_invalid;
13850 }
13851
13852
1/2
✓ Branch 0 taken 58880 times.
✗ Branch 1 not taken.
58880 if(!p_igetw(&(tempguy.grumble),f))
13853 {
13854 return qe_invalid;
13855 }
13856
13857
1/2
✓ Branch 0 taken 58880 times.
✗ Branch 1 not taken.
58880 if(!p_igetw(&(tempguy.item_set),f))
13858 {
13859 return qe_invalid;
13860 }
13861
13862
1/2
✓ Branch 0 taken 58880 times.
✗ Branch 1 not taken.
58880 if(guyversion>=22) // Version 22: Expand misc attributes to 32 bits
13863 {
13864
1/2
✓ Branch 0 taken 58880 times.
✗ Branch 1 not taken.
58880 if(!p_igetl(&(tempguy.misc1),f))
13865 {
13866 return qe_invalid;
13867 }
13868
13869
1/2
✓ Branch 0 taken 58880 times.
✗ Branch 1 not taken.
58880 if(!p_igetl(&(tempguy.misc2),f))
13870 {
13871 return qe_invalid;
13872 }
13873
13874
1/2
✓ Branch 0 taken 58880 times.
✗ Branch 1 not taken.
58880 if(!p_igetl(&(tempguy.misc3),f))
13875 {
13876 return qe_invalid;
13877 }
13878
13879
1/2
✓ Branch 0 taken 58880 times.
✗ Branch 1 not taken.
58880 if(!p_igetl(&(tempguy.misc4),f))
13880 {
13881 return qe_invalid;
13882 }
13883
13884
1/2
✓ Branch 0 taken 58880 times.
✗ Branch 1 not taken.
58880 if(!p_igetl(&(tempguy.misc5),f))
13885 {
13886 return qe_invalid;
13887 }
13888
13889
1/2
✓ Branch 0 taken 58880 times.
✗ Branch 1 not taken.
58880 if(!p_igetl(&(tempguy.misc6),f))
13890 {
13891 return qe_invalid;
13892 }
13893
13894
1/2
✓ Branch 0 taken 58880 times.
✗ Branch 1 not taken.
58880 if(!p_igetl(&(tempguy.misc7),f))
13895 {
13896 return qe_invalid;
13897 }
13898
13899
1/2
✓ Branch 0 taken 58880 times.
✗ Branch 1 not taken.
58880 if(!p_igetl(&(tempguy.misc8),f))
13900 {
13901 return qe_invalid;
13902 }
13903
13904
1/2
✓ Branch 0 taken 58880 times.
✗ Branch 1 not taken.
58880 if(!p_igetl(&(tempguy.misc9),f))
13905 {
13906 return qe_invalid;
13907 }
13908
13909
1/2
✓ Branch 0 taken 58880 times.
✗ Branch 1 not taken.
58880 if(!p_igetl(&(tempguy.misc10),f))
13910 {
13911 return qe_invalid;
13912 }
13913 58880 }
13914 else
13915 {
13916 int16_t tempMisc;
13917
13918 if(!p_igetw(&tempMisc,f))
13919 {
13920 return qe_invalid;
13921 }
13922
13923 tempguy.misc1=tempMisc;
13924
13925 if(!p_igetw(&tempMisc,f))
13926 {
13927 return qe_invalid;
13928 }
13929
13930 tempguy.misc2=tempMisc;
13931
13932 if(!p_igetw(&tempMisc,f))
13933 {
13934 return qe_invalid;
13935 }
13936
13937 tempguy.misc3=tempMisc;
13938
13939 if(!p_igetw(&tempMisc,f))
13940 {
13941 return qe_invalid;
13942 }
13943
13944 tempguy.misc4=tempMisc;
13945
13946 if(!p_igetw(&tempMisc,f))
13947 {
13948 return qe_invalid;
13949 }
13950
13951 tempguy.misc5=tempMisc;
13952
13953 if(guyversion < 13) // April 2009 - a tiny Wizzrobe update
13954 {
13955 if(tempguy.family == eeWIZZ && !(tempguy.misc1))
13956 tempguy.misc5 = 74;
13957 }
13958
13959 if(!p_igetw(&tempMisc,f))
13960 {
13961 return qe_invalid;
13962 }
13963
13964 tempguy.misc6=tempMisc;
13965
13966 if(!p_igetw(&tempMisc,f))
13967 {
13968 return qe_invalid;
13969 }
13970
13971 tempguy.misc7=tempMisc;
13972
13973 if(!p_igetw(&tempMisc,f))
13974 {
13975 return qe_invalid;
13976 }
13977
13978 tempguy.misc8=tempMisc;
13979
13980 if(!p_igetw(&tempMisc,f))
13981 {
13982 return qe_invalid;
13983 }
13984
13985 tempguy.misc9=tempMisc;
13986
13987 if(!p_igetw(&tempMisc,f))
13988 {
13989 return qe_invalid;
13990 }
13991
13992 tempguy.misc10=tempMisc;
13993 }
13994
13995
1/2
✓ Branch 0 taken 58880 times.
✗ Branch 1 not taken.
58880 if(!p_igetw(&(tempguy.bgsfx),f))
13996 {
13997 return qe_invalid;
13998 }
13999
14000
1/2
✓ Branch 0 taken 58880 times.
✗ Branch 1 not taken.
58880 if(!p_igetw(&(tempguy.bosspal),f))
14001 {
14002 return qe_invalid;
14003 }
14004
14005
1/2
✓ Branch 0 taken 58880 times.
✗ Branch 1 not taken.
58880 if(!p_igetw(&(tempguy.extend),f))
14006 {
14007 return qe_invalid;
14008 }
14009
14010 //! Enemy Defences
14011
14012 //If a 2.50 quest, use only the 2.5 defences.
14013
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 58880 times.
58880 if(guyversion >= 16 ) // November 2009 - Super Enemy Editor
14014 {
14015
2/2
✓ Branch 0 taken 1118720 times.
✓ Branch 1 taken 58880 times.
1177600 for(int32_t j=0; j<edefLAST; j++)
14016 {
14017
1/2
✓ Branch 0 taken 1118720 times.
✗ Branch 1 not taken.
1118720 if(!p_getc(&(tempguy.defense[j]),f))
14018 {
14019 return qe_invalid;
14020 }
14021 1118720 }
14022 //then copy the generic script defence to all the new script defences
14023
14024 58880 }
14025
14026
14027
14028
14029
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 58880 times.
58880 if(guyversion >= 18)
14030 {
14031
1/2
✓ Branch 0 taken 58880 times.
✗ Branch 1 not taken.
58880 if(!p_getc(&(tempguy.hitsfx),f))
14032 {
14033 return qe_invalid;
14034 }
14035
14036
1/2
✓ Branch 0 taken 58880 times.
✗ Branch 1 not taken.
58880 if(!p_getc(&(tempguy.deadsfx),f))
14037 {
14038 return qe_invalid;
14039 }
14040 58880 }
14041
14042
1/2
✓ Branch 0 taken 58880 times.
✗ Branch 1 not taken.
58880 if(guyversion >= 22)
14043 {
14044
1/2
✓ Branch 0 taken 58880 times.
✗ Branch 1 not taken.
58880 if(!p_igetl(&(tempguy.misc11),f))
14045 {
14046 return qe_invalid;
14047 }
14048
14049
1/2
✓ Branch 0 taken 58880 times.
✗ Branch 1 not taken.
58880 if(!p_igetl(&(tempguy.misc12),f))
14050 {
14051 return qe_invalid;
14052 }
14053 58880 }
14054 else if(guyversion >= 19)
14055 {
14056 int16_t tempMisc;
14057
14058 if(!p_igetw(&tempMisc,f))
14059 {
14060 return qe_invalid;
14061 }
14062
14063 tempguy.misc11=tempMisc;
14064
14065 if(!p_igetw(&tempMisc,f))
14066 {
14067 return qe_invalid;
14068 }
14069
14070 tempguy.misc12=tempMisc;
14071 }
14072
14073 //If a 2.54 or later quest, use all of the defences.
14074
2/2
✓ Branch 0 taken 39424 times.
✓ Branch 1 taken 19456 times.
58880 if(guyversion > 24) // Add new guyversion conditional statement
14075 {
14076
2/2
✓ Branch 0 taken 428032 times.
✓ Branch 1 taken 19456 times.
447488 for(int32_t j=edefLAST; j<edefLAST255; j++)
14077 {
14078
1/2
✓ Branch 0 taken 428032 times.
✗ Branch 1 not taken.
428032 if(!p_getc(&(tempguy.defense[j]),f))
14079 {
14080 return qe_invalid;
14081 }
14082 428032 }
14083 19456 }
14084
14085
2/2
✓ Branch 0 taken 19456 times.
✓ Branch 1 taken 39424 times.
58880 if(guyversion <= 24) // Port over generic script settings from old quests in the new editor.
14086 {
14087
2/2
✓ Branch 0 taken 394240 times.
✓ Branch 1 taken 39424 times.
433664 for(int32_t j=edefSCRIPT01; j<=edefSCRIPT10; j++)
14088 {
14089 394240 tempguy.defense[j] = tempguy.defense[edefSCRIPT] ;
14090 394240 }
14091 39424 }
14092
14093 //tilewidth, tileheight, hitwidth, hitheight, hitzheight, hitxofs, hityofs, hitzofs
14094
2/2
✓ Branch 0 taken 39424 times.
✓ Branch 1 taken 19456 times.
58880 if(guyversion > 25)
14095 {
14096
1/2
✓ Branch 0 taken 19456 times.
✗ Branch 1 not taken.
19456 if(!p_igetl(&(tempguy.txsz),f))
14097 {
14098 return qe_invalid;
14099 }
14100
1/2
✓ Branch 0 taken 19456 times.
✗ Branch 1 not taken.
19456 if(!p_igetl(&(tempguy.tysz),f))
14101 {
14102 return qe_invalid;
14103 }
14104
1/2
✓ Branch 0 taken 19456 times.
✗ Branch 1 not taken.
19456 if(!p_igetl(&(tempguy.hxsz),f))
14105 {
14106 return qe_invalid;
14107 }
14108
1/2
✓ Branch 0 taken 19456 times.
✗ Branch 1 not taken.
19456 if(!p_igetl(&(tempguy.hysz),f))
14109 {
14110 return qe_invalid;
14111 }
14112
1/2
✓ Branch 0 taken 19456 times.
✗ Branch 1 not taken.
19456 if(!p_igetl(&(tempguy.hzsz),f))
14113 {
14114 return qe_invalid;
14115 }
14116 /* Is it safe to read a fixed with getl, or do I need to typecast it? -Z
14117
14118 */
14119 19456 }
14120 //More Enemy Editor vars for 2.60
14121
2/2
✓ Branch 0 taken 39424 times.
✓ Branch 1 taken 19456 times.
58880 if(guyversion > 26)
14122 {
14123
1/2
✓ Branch 0 taken 19456 times.
✗ Branch 1 not taken.
19456 if(!p_igetl(&(tempguy.hxofs),f))
14124 {
14125 return qe_invalid;
14126 }
14127
1/2
✓ Branch 0 taken 19456 times.
✗ Branch 1 not taken.
19456 if(!p_igetl(&(tempguy.hyofs),f))
14128 {
14129 return qe_invalid;
14130 }
14131
1/2
✓ Branch 0 taken 19456 times.
✗ Branch 1 not taken.
19456 if(!p_igetl(&(tempguy.xofs),f))
14132 {
14133 return qe_invalid;
14134 }
14135
1/2
✓ Branch 0 taken 19456 times.
✗ Branch 1 not taken.
19456 if(!p_igetl(&(tempguy.yofs),f))
14136 {
14137 return qe_invalid;
14138 }
14139
1/2
✓ Branch 0 taken 19456 times.
✗ Branch 1 not taken.
19456 if(!p_igetl(&(tempguy.zofs),f))
14140 {
14141 return qe_invalid;
14142 }
14143 19456 }
14144
14145
2/2
✓ Branch 0 taken 19456 times.
✓ Branch 1 taken 39424 times.
58880 if(guyversion <= 27) // Port over generic script settings from old quests in the new editor.
14146 {
14147 39424 tempguy.wpnsprite = 0;
14148 39424 }
14149
14150
2/2
✓ Branch 0 taken 39424 times.
✓ Branch 1 taken 19456 times.
58880 if(guyversion > 27)
14151 {
14152
1/2
✓ Branch 0 taken 19456 times.
✗ Branch 1 not taken.
19456 if(!p_igetl(&(tempguy.wpnsprite),f))
14153 {
14154 return qe_invalid;
14155 }
14156 19456 }
14157
2/2
✓ Branch 0 taken 19456 times.
✓ Branch 1 taken 39424 times.
58880 if(guyversion <= 28) // Port over generic script settings from old quests in the new editor.
14158 {
14159 39424 tempguy.SIZEflags = 0;
14160 39424 }
14161
2/2
✓ Branch 0 taken 39424 times.
✓ Branch 1 taken 19456 times.
58880 if(guyversion > 28)
14162 {
14163
1/2
✓ Branch 0 taken 19456 times.
✗ Branch 1 not taken.
19456 if(!p_igetl(&(tempguy.SIZEflags),f))
14164 {
14165 return qe_invalid;
14166 }
14167
14168 19456 }
14169
2/2
✓ Branch 0 taken 19456 times.
✓ Branch 1 taken 39424 times.
58880 if(guyversion < 30) // Port over generic script settings from old quests in the new editor.
14170 {
14171 39424 tempguy.frozentile = 0;
14172 39424 tempguy.frozencset = 0;
14173 39424 tempguy.frozenclock = 0;
14174
2/2
✓ Branch 0 taken 394240 times.
✓ Branch 1 taken 39424 times.
433664 for ( int32_t q = 0; q < 10; q++ ) tempguy.frozenmisc[q] = 0;
14175 39424 }
14176
2/2
✓ Branch 0 taken 39424 times.
✓ Branch 1 taken 19456 times.
58880 if(guyversion >= 30)
14177 {
14178
1/2
✓ Branch 0 taken 19456 times.
✗ Branch 1 not taken.
19456 if(!p_igetl(&(tempguy.frozentile),f))
14179 {
14180 return qe_invalid;
14181 }
14182
1/2
✓ Branch 0 taken 19456 times.
✗ Branch 1 not taken.
19456 if(!p_igetl(&(tempguy.frozencset),f))
14183 {
14184 return qe_invalid;
14185 }
14186
1/2
✓ Branch 0 taken 19456 times.
✗ Branch 1 not taken.
19456 if(!p_igetl(&(tempguy.frozenclock),f))
14187 {
14188 return qe_invalid;
14189 }
14190
2/2
✓ Branch 0 taken 194560 times.
✓ Branch 1 taken 19456 times.
214016 for ( int32_t q = 0; q < 10; q++ ) {
14191
1/2
✓ Branch 0 taken 194560 times.
✗ Branch 1 not taken.
194560 if(!p_igetw(&(tempguy.frozenmisc[q]),f))
14192 {
14193 return qe_invalid;
14194 }
14195 194560 }
14196
14197 19456 }
14198
14199
2/2
✓ Branch 0 taken 39424 times.
✓ Branch 1 taken 19456 times.
58880 if(guyversion >= 34)
14200 {
14201
1/2
✓ Branch 0 taken 19456 times.
✗ Branch 1 not taken.
19456 if(!p_igetw(&(tempguy.firesfx),f))
14202 {
14203 return qe_invalid;
14204 }
14205
1/2
✓ Branch 0 taken 19456 times.
✗ Branch 1 not taken.
19456 if(!p_igetl(&(tempguy.misc16),f))
14206 {
14207 return qe_invalid;
14208 }
14209
1/2
✓ Branch 0 taken 19456 times.
✗ Branch 1 not taken.
19456 if(!p_igetl(&(tempguy.misc17),f))
14210 {
14211 return qe_invalid;
14212 }
14213
1/2
✓ Branch 0 taken 19456 times.
✗ Branch 1 not taken.
19456 if(!p_igetl(&(tempguy.misc18),f))
14214 {
14215 return qe_invalid;
14216 }
14217
1/2
✓ Branch 0 taken 19456 times.
✗ Branch 1 not taken.
19456 if(!p_igetl(&(tempguy.misc19),f))
14218 {
14219 return qe_invalid;
14220 }
14221
1/2
✓ Branch 0 taken 19456 times.
✗ Branch 1 not taken.
19456 if(!p_igetl(&(tempguy.misc20),f))
14222 {
14223 return qe_invalid;
14224 }
14225
1/2
✓ Branch 0 taken 19456 times.
✗ Branch 1 not taken.
19456 if(!p_igetl(&(tempguy.misc21),f))
14226 {
14227 return qe_invalid;
14228 }
14229
1/2
✓ Branch 0 taken 19456 times.
✗ Branch 1 not taken.
19456 if(!p_igetl(&(tempguy.misc22),f))
14230 {
14231 return qe_invalid;
14232 }
14233
1/2
✓ Branch 0 taken 19456 times.
✗ Branch 1 not taken.
19456 if(!p_igetl(&(tempguy.misc23),f))
14234 {
14235 return qe_invalid;
14236 }
14237
1/2
✓ Branch 0 taken 19456 times.
✗ Branch 1 not taken.
19456 if(!p_igetl(&(tempguy.misc24),f))
14238 {
14239 return qe_invalid;
14240 }
14241
1/2
✓ Branch 0 taken 19456 times.
✗ Branch 1 not taken.
19456 if(!p_igetl(&(tempguy.misc25),f))
14242 {
14243 return qe_invalid;
14244 }
14245
1/2
✓ Branch 0 taken 19456 times.
✗ Branch 1 not taken.
19456 if(!p_igetl(&(tempguy.misc26),f))
14246 {
14247 return qe_invalid;
14248 }
14249
1/2
✓ Branch 0 taken 19456 times.
✗ Branch 1 not taken.
19456 if(!p_igetl(&(tempguy.misc27),f))
14250 {
14251 return qe_invalid;
14252 }
14253
1/2
✓ Branch 0 taken 19456 times.
✗ Branch 1 not taken.
19456 if(!p_igetl(&(tempguy.misc28),f))
14254 {
14255 return qe_invalid;
14256 }
14257
1/2
✓ Branch 0 taken 19456 times.
✗ Branch 1 not taken.
19456 if(!p_igetl(&(tempguy.misc29),f))
14258 {
14259 return qe_invalid;
14260 }
14261
1/2
✓ Branch 0 taken 19456 times.
✗ Branch 1 not taken.
19456 if(!p_igetl(&(tempguy.misc30),f))
14262 {
14263 return qe_invalid;
14264 }
14265
1/2
✓ Branch 0 taken 19456 times.
✗ Branch 1 not taken.
19456 if(!p_igetl(&(tempguy.misc31),f))
14266 {
14267 return qe_invalid;
14268 }
14269
1/2
✓ Branch 0 taken 19456 times.
✗ Branch 1 not taken.
19456 if(!p_igetl(&(tempguy.misc32),f))
14270 {
14271 return qe_invalid;
14272 }
14273
14274
2/2
✓ Branch 0 taken 622592 times.
✓ Branch 1 taken 19456 times.
642048 for ( int32_t q = 0; q < 32; q++ ) {
14275
1/2
✓ Branch 0 taken 622592 times.
✗ Branch 1 not taken.
622592 if(!p_igetl(&(tempguy.movement[q]),f))
14276 {
14277 return qe_invalid;
14278 }
14279 622592 }
14280
2/2
✓ Branch 0 taken 622592 times.
✓ Branch 1 taken 19456 times.
642048 for ( int32_t q = 0; q < 32; q++ ) {
14281
1/2
✓ Branch 0 taken 622592 times.
✗ Branch 1 not taken.
622592 if(!p_igetl(&(tempguy.new_weapon[q]),f))
14282 {
14283 return qe_invalid;
14284 }
14285 622592 }
14286
1/2
✓ Branch 0 taken 19456 times.
✗ Branch 1 not taken.
19456 if(!p_igetw(&(tempguy.script),f))
14287 {
14288 return qe_invalid;
14289 }
14290 //al_trace("NPC Script ID is: %d\n",tempguy.script);
14291
2/2
✓ Branch 0 taken 155648 times.
✓ Branch 1 taken 19456 times.
175104 for ( int32_t q = 0; q < 8; q++ )
14292 {
14293
1/2
✓ Branch 0 taken 155648 times.
✗ Branch 1 not taken.
155648 if(!p_igetl(&(tempguy.initD[q]),f))
14294 {
14295 return qe_invalid;
14296 }
14297 155648 }
14298
2/2
✓ Branch 0 taken 38912 times.
✓ Branch 1 taken 19456 times.
58368 for ( int32_t q = 0; q < 2; q++ )
14299 {
14300
1/2
✓ Branch 0 taken 38912 times.
✗ Branch 1 not taken.
38912 if(!p_igetl(&(tempguy.initA[q]),f))
14301 {
14302 return qe_invalid;
14303 }
14304 38912 }
14305
14306 19456 }
14307
14308
2/2
✓ Branch 0 taken 39424 times.
✓ Branch 1 taken 19456 times.
58880 if(guyversion >= 37)
14309 {
14310
1/2
✓ Branch 0 taken 19456 times.
✗ Branch 1 not taken.
19456 if(!p_igetl(&(tempguy.editorflags),f))
14311 {
14312 return qe_invalid;
14313 }
14314 19456 }
14315
2/2
✓ Branch 0 taken 19456 times.
✓ Branch 1 taken 39424 times.
58880 if ( guyversion < 37 ) { tempguy.editorflags = 0; }
14316
2/2
✓ Branch 0 taken 39424 times.
✓ Branch 1 taken 19456 times.
58880 if(guyversion >= 38)
14317 {
14318
1/2
✓ Branch 0 taken 19456 times.
✗ Branch 1 not taken.
19456 if(!p_igetl(&(tempguy.misc13),f))
14319 {
14320 return qe_invalid;
14321 }
14322
1/2
✓ Branch 0 taken 19456 times.
✗ Branch 1 not taken.
19456 if(!p_igetl(&(tempguy.misc14),f))
14323 {
14324 return qe_invalid;
14325 }
14326
1/2
✓ Branch 0 taken 19456 times.
✗ Branch 1 not taken.
19456 if(!p_igetl(&(tempguy.misc15),f))
14327 {
14328 return qe_invalid;
14329 }
14330
14331 19456 }
14332
2/2
✓ Branch 0 taken 19456 times.
✓ Branch 1 taken 39424 times.
58880 if ( guyversion < 38 )
14333 {
14334 39424 tempguy.misc13 = 0;
14335 39424 tempguy.misc14 = 0;
14336 39424 tempguy.misc15 = 0;
14337 39424 }
14338
14339
2/2
✓ Branch 0 taken 39424 times.
✓ Branch 1 taken 19456 times.
58880 if ( guyversion >= 39 )
14340 {
14341
2/2
✓ Branch 0 taken 155648 times.
✓ Branch 1 taken 19456 times.
175104 for ( int32_t q = 0; q < 8; q++ )
14342 {
14343
2/2
✓ Branch 0 taken 10117120 times.
✓ Branch 1 taken 155648 times.
10272768 for ( int32_t w = 0; w < 65; w++ )
14344 {
14345
1/2
✓ Branch 0 taken 10117120 times.
✗ Branch 1 not taken.
10117120 if(!p_getc(&(tempguy.initD_label[q][w]),f))
14346 {
14347 return qe_invalid;
14348 }
14349 10117120 }
14350
2/2
✓ Branch 0 taken 10117120 times.
✓ Branch 1 taken 155648 times.
10272768 for ( int32_t w = 0; w < 65; w++ )
14351 {
14352
1/2
✓ Branch 0 taken 10117120 times.
✗ Branch 1 not taken.
10117120 if(!p_getc(&(tempguy.weapon_initD_label[q][w]),f))
14353 {
14354 return qe_invalid;
14355 }
14356 10117120 }
14357 155648 }
14358
14359
14360 19456 }
14361
2/2
✓ Branch 0 taken 19456 times.
✓ Branch 1 taken 39424 times.
58880 if ( guyversion < 39 ) //apply old InitD strings to both
14362 {
14363
2/2
✓ Branch 0 taken 315392 times.
✓ Branch 1 taken 39424 times.
354816 for ( int32_t q = 0; q < 8; q++ )
14364 {
14365 315392 sprintf(tempguy.initD_label[q],"InitD[%d]",q);
14366 315392 sprintf(tempguy.weapon_initD_label[q],"InitD[%d]",q);
14367 315392 }
14368 39424 }
14369
2/2
✓ Branch 0 taken 39424 times.
✓ Branch 1 taken 19456 times.
58880 if ( guyversion >= 40 )
14370 {
14371
1/2
✓ Branch 0 taken 19456 times.
✗ Branch 1 not taken.
19456 if(!p_igetw(&(tempguy.weaponscript),f))
14372 {
14373 return qe_invalid;
14374 }
14375 19456 }
14376
2/2
✓ Branch 0 taken 19456 times.
✓ Branch 1 taken 39424 times.
58880 if ( guyversion < 40 )
14377 {
14378 39424 tempguy.weaponscript = 0;
14379 39424 }
14380 //eweapon script InitD
14381
2/2
✓ Branch 0 taken 39424 times.
✓ Branch 1 taken 19456 times.
58880 if ( guyversion >= 41 )
14382 {
14383
2/2
✓ Branch 0 taken 155648 times.
✓ Branch 1 taken 19456 times.
175104 for ( int32_t q = 0; q < 8; q++ )
14384 {
14385
1/2
✓ Branch 0 taken 155648 times.
✗ Branch 1 not taken.
155648 if(!p_igetl(&(tempguy.weap_initiald[q]),f))
14386 {
14387 return qe_invalid;
14388 }
14389 155648 }
14390
1/2
✓ Branch 0 taken 19456 times.
✗ Branch 1 not taken.
19456 if ( guy_cversion < 4 )
14391 {
14392 if ( tempguy.family == eeKEESE )
14393 {
14394
14395 if ( !tempguy.misc1 )
14396 {
14397 tempguy.misc16 = 120;
14398 tempguy.misc17 = 16;
14399
14400 }
14401 }
14402 if ( tempguy.family == eePEAHAT )
14403 {
14404 tempguy.misc16 = 80;
14405 tempguy.misc17 = 16;
14406 }
14407
14408 if ( tempguy.family == eeGHINI )
14409 {
14410 tempguy.misc16 = 120;
14411 tempguy.misc17 = 10;
14412 }
14413
14414 }
14415 19456 }
14416
14417
14418
14419 //default weapon sprites (quest version < 2.54)
14420 //port over old defaults -Z
14421
2/2
✓ Branch 0 taken 19456 times.
✓ Branch 1 taken 39424 times.
58880 if(guyversion < 32)
14422 {
14423
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 39424 times.
39424 if ( tempguy.wpnsprite <= 0 )
14424 {
14425
16/20
✗ Branch 0 not taken.
✓ Branch 1 taken 1303 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 32842 times.
✓ Branch 4 taken 302 times.
✓ Branch 5 taken 314 times.
✓ Branch 6 taken 931 times.
✓ Branch 7 taken 493 times.
✓ Branch 8 taken 912 times.
✓ Branch 9 taken 80 times.
✓ Branch 10 taken 18 times.
✓ Branch 11 taken 137 times.
✓ Branch 12 taken 19 times.
✓ Branch 13 taken 363 times.
✓ Branch 14 taken 759 times.
✓ Branch 15 taken 106 times.
✓ Branch 16 taken 80 times.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✓ Branch 19 taken 765 times.
39424 switch(tempguy.weapon)
14426 {
14427 case wNone:
14428 32842 tempguy.wpnsprite = 0; break;
14429
14430 case wSword:
14431 case wBeam:
14432 case wBrang:
14433 case wBomb:
14434 case wSBomb:
14435 case wLitBomb:
14436 case wLitSBomb:
14437 case wArrow:
14438 case wFire:
14439 case wWhistle:
14440 case wBait:
14441 case wWand:
14442 case wMagic:
14443 case wCatching:
14444 case wWind:
14445 case wRefMagic:
14446 case wRefFireball:
14447 case wRefRock:
14448 case wHammer:
14449 case wHookshot:
14450 case wHSHandle:
14451 case wHSChain:
14452 case wSSparkle:
14453 case wFSparkle:
14454 case wSmack:
14455 case wPhantom:
14456 case wCByrna:
14457 case wRefBeam:
14458 case wStomp:
14459 case lwMax:
14460 case wScript1:
14461 case wScript2:
14462 case wScript3:
14463 case wScript4:
14464 case wScript5:
14465 case wScript6:
14466 case wScript7:
14467 case wScript8:
14468 case wScript9:
14469 case wScript10:
14470 case wIce:
14471 //Cannot use any of these weapons yet.
14472 tempguy.wpnsprite = -1;
14473 break;
14474
14475 case wEnemyWeapons:
14476 1303 case ewFireball: tempguy.wpnsprite = 17; break;
14477
14478 302 case ewArrow: tempguy.wpnsprite = 19; break;
14479 314 case ewBrang: tempguy.wpnsprite = 4; break;
14480 931 case ewSword: tempguy.wpnsprite = 20; break;
14481 493 case ewRock: tempguy.wpnsprite = 18; break;
14482 912 case ewMagic: tempguy.wpnsprite = 21; break;
14483 80 case ewBomb: tempguy.wpnsprite = 78; break;
14484 18 case ewSBomb: tempguy.wpnsprite = 79; break;
14485 137 case ewLitBomb: tempguy.wpnsprite = 76; break;
14486 19 case ewLitSBomb: tempguy.wpnsprite = 77; break;
14487 363 case ewFireTrail: tempguy.wpnsprite = 80; break;
14488 759 case ewFlame: tempguy.wpnsprite = 35; break;
14489 106 case ewWind: tempguy.wpnsprite = 36; break;
14490 80 case ewFlame2: tempguy.wpnsprite = 81; break;
14491 case ewFlame2Trail: tempguy.wpnsprite = 82; break;
14492 case ewIce: tempguy.wpnsprite = 83; break;
14493 765 case ewFireball2: tempguy.wpnsprite = 17; break; //fireball (rising)
14494
14495
14496 default: break; //No assign.
14497 }
14498 39424 }
14499 39424 }
14500
14501 //default weapon fire sound (quest version < 2.54)
14502 //port over old defaults and zero new data. -Z
14503
2/2
✓ Branch 0 taken 19456 times.
✓ Branch 1 taken 39424 times.
58880 if(guyversion < 34)
14504 {
14505
2/2
✓ Branch 0 taken 1261568 times.
✓ Branch 1 taken 39424 times.
1300992 for ( int32_t q = 0; q < 32; q++ )
14506 {
14507 1261568 tempguy.movement[q] = 0;
14508 1261568 tempguy.new_weapon[q] = 0;
14509
14510 1261568 }
14511
14512 //NPC Script attributes.
14513 39424 tempguy.script = 0; //No scripted enemies existed. -Z
14514
2/2
✓ Branch 0 taken 315392 times.
✓ Branch 1 taken 39424 times.
354816 for ( int32_t q = 0; q < 8; q++ ) tempguy.initD[q] = 0; //Script Data
14515
2/2
✓ Branch 0 taken 78848 times.
✓ Branch 1 taken 39424 times.
118272 for ( int32_t q = 0; q < 2; q++ ) tempguy.initA[q] = 0; //Script Data
14516
14517 39424 tempguy.misc16 = 0;
14518 39424 tempguy.misc17 = 0;
14519 39424 tempguy.misc18 = 0;
14520 39424 tempguy.misc19 = 0;
14521 39424 tempguy.misc20 = 0;
14522 39424 tempguy.misc21 = 0;
14523 39424 tempguy.misc22 = 0;
14524 39424 tempguy.misc23 = 0;
14525 39424 tempguy.misc24 = 0;
14526 39424 tempguy.misc25 = 0;
14527 39424 tempguy.misc26 = 0;
14528 39424 tempguy.misc27 = 0;
14529 39424 tempguy.misc28 = 0;
14530 39424 tempguy.misc29 = 0;
14531 39424 tempguy.misc30 = 0;
14532 39424 tempguy.misc31 = 0;
14533 39424 tempguy.misc32 = 0;
14534
14535 //old default sounds
14536
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 39424 times.
39424 if ( tempguy.firesfx <= 0 )
14537 {
14538
16/20
✗ Branch 0 not taken.
✓ Branch 1 taken 1303 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 32842 times.
✓ Branch 4 taken 302 times.
✓ Branch 5 taken 314 times.
✓ Branch 6 taken 931 times.
✓ Branch 7 taken 493 times.
✓ Branch 8 taken 912 times.
✓ Branch 9 taken 80 times.
✓ Branch 10 taken 18 times.
✓ Branch 11 taken 137 times.
✓ Branch 12 taken 19 times.
✓ Branch 13 taken 363 times.
✓ Branch 14 taken 759 times.
✓ Branch 15 taken 106 times.
✓ Branch 16 taken 80 times.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✓ Branch 19 taken 765 times.
39424 switch(tempguy.weapon)
14539 {
14540 case wNone:
14541 32842 tempguy.firesfx = 0; break;
14542
14543 case wSword:
14544 case wBeam:
14545 case wBrang:
14546 case wBomb:
14547 case wSBomb:
14548 case wLitBomb:
14549 case wLitSBomb:
14550 case wArrow:
14551 case wFire:
14552 case wWhistle:
14553 case wBait:
14554 case wWand:
14555 case wMagic:
14556 case wCatching:
14557 case wWind:
14558 case wRefMagic:
14559 case wRefFireball:
14560 case wRefRock:
14561 case wHammer:
14562 case wHookshot:
14563 case wHSHandle:
14564 case wHSChain:
14565 case wSSparkle:
14566 case wFSparkle:
14567 case wSmack:
14568 case wPhantom:
14569 case wCByrna:
14570 case wRefBeam:
14571 case wStomp:
14572 case lwMax:
14573 case wScript1:
14574 case wScript2:
14575 case wScript3:
14576 case wScript4:
14577 case wScript5:
14578 case wScript6:
14579 case wScript7:
14580 case wScript8:
14581 case wScript9:
14582 case wScript10:
14583 case wIce:
14584 //Cannot use any of these weapons yet.
14585 tempguy.firesfx = -1;
14586 break;
14587
14588 case wEnemyWeapons:
14589 1303 case ewFireball: tempguy.firesfx = 40; break;
14590
14591 302 case ewArrow: tempguy.firesfx = 1; break; //Ghost.zh has 0?
14592 314 case ewBrang: tempguy.firesfx = 4; break; //Ghost.zh has 0?
14593 931 case ewSword: tempguy.firesfx = 20; break; //Ghost.zh has 0?
14594 493 case ewRock: tempguy.firesfx = 51; break;
14595 912 case ewMagic: tempguy.firesfx = 32; break;
14596 80 case ewBomb: tempguy.firesfx = 3; break; //Ghost.zh has 0?
14597 18 case ewSBomb: tempguy.firesfx = 3; break; //Ghost.zh has 0?
14598 137 case ewLitBomb: tempguy.firesfx = 21; break; //Ghost.zh has 0?
14599 19 case ewLitSBomb: tempguy.firesfx = 21; break; //Ghost.zh has 0?
14600 363 case ewFireTrail: tempguy.firesfx = 13; break;
14601 759 case ewFlame: tempguy.firesfx = 13; break;
14602 106 case ewWind: tempguy.firesfx = 32; break;
14603 80 case ewFlame2: tempguy.firesfx = 13; break;
14604 case ewFlame2Trail: tempguy.firesfx = 13; break;
14605 case ewIce: tempguy.firesfx = 44; break;
14606 765 case ewFireball2: tempguy.firesfx = 40; break; //fireball (rising)
14607
14608 //what about special attacks (e.g. summoning == 56)
14609 default: break; //No assign.
14610 }
14611 39424 }
14612 39424 }
14613
14614 //Port hardcoded hit sound to the enemy hitsfx defaults for older quests.
14615
4/6
✓ Branch 0 taken 19456 times.
✓ Branch 1 taken 39424 times.
✓ Branch 2 taken 19456 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 19456 times.
58880 if(Header->zelda_version <= 0x250 || ( Header->zelda_version > 0x250 && guyversion < 35 ))
14616 {
14617
2/2
✓ Branch 0 taken 3549 times.
✓ Branch 1 taken 35875 times.
39424 if ( tempguy.hitsfx == 0 ) tempguy.hitsfx = 11;
14618 39424 }
14619 //Keese and bat halt rates.
14620
3/4
✓ Branch 0 taken 39424 times.
✓ Branch 1 taken 19456 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 39424 times.
58880 if ( guyversion < 42 && guy_cversion < 4 )
14621 {
14622
14623
2/2
✓ Branch 0 taken 38895 times.
✓ Branch 1 taken 529 times.
39424 if ( tempguy.family == eeKEESE )
14624 {
14625
14626
2/2
✓ Branch 0 taken 203 times.
✓ Branch 1 taken 326 times.
529 if ( !tempguy.misc1 )
14627 {
14628 326 tempguy.misc16 = 120;
14629 326 tempguy.misc17 = 16;
14630
14631 326 }
14632 529 }
14633
2/2
✓ Branch 0 taken 39257 times.
✓ Branch 1 taken 167 times.
39424 if ( tempguy.family == eePEAHAT )
14634 {
14635 167 tempguy.misc16 = 80;
14636 167 tempguy.misc17 = 16;
14637 167 }
14638
2/2
✓ Branch 0 taken 39347 times.
✓ Branch 1 taken 77 times.
39424 if ( tempguy.family == eeGHINI )
14639 {
14640 77 tempguy.misc16 = 120;
14641 77 tempguy.misc17 = 10;
14642 77 }
14643
14644
14645 39424 }
14646
14647
14648 //miscellaneous other corrections
14649 //fix the mirror wizzrobe -DD
14650
1/2
✓ Branch 0 taken 58880 times.
✗ Branch 1 not taken.
58880 if(guyversion < 7)
14651 {
14652 if(i == eMWIZ)
14653 {
14654 tempguy.misc2 = 0;
14655 tempguy.misc4 = 1;
14656 }
14657 }
14658
14659
1/2
✓ Branch 0 taken 58880 times.
✗ Branch 1 not taken.
58880 if(guyversion < 8)
14660 {
14661 if(i == eGLEEOK1 || i == eGLEEOK2 || i == eGLEEOK3 || i == eGLEEOK4 || i == eGLEEOK1F || i == eGLEEOK2F || i == eGLEEOK3F || i == eGLEEOK4F)
14662 {
14663 // Some of these are deliberately different to NewDefault/defdata.cpp, by the way. -L
14664 tempguy.misc5 = 4; //neck length in segments
14665 tempguy.misc6 = 8; //neck offset from first body tile
14666 tempguy.misc7 = 40; //offset for each subsequent neck tile from the first neck tile
14667 tempguy.misc8 = 168; //head offset from first body tile
14668 tempguy.misc9 = 228; //flying head offset from first body tile
14669
14670 if(i == eGLEEOK1F || i == eGLEEOK2F || i == eGLEEOK3F || i == eGLEEOK4F)
14671 {
14672 tempguy.misc6 += 10; //neck offset from first body tile
14673 tempguy.misc8 -= 12; //head offset from first body tile
14674 }
14675 }
14676 }
14677
14678
1/2
✓ Branch 0 taken 58880 times.
✗ Branch 1 not taken.
58880 if(guyversion < 10) // December 2007 - Dodongo CSet fix
14679 {
14680 if(get_bit(deprecated_rules,46) && tempguy.family==eeDONGO && tempguy.misc1==0)
14681 tempguy.bosspal = spDIG;
14682 }
14683
14684
1/2
✓ Branch 0 taken 58880 times.
✗ Branch 1 not taken.
58880 if(guyversion < 11) // December 2007 - Spinning Tile fix
14685 {
14686 if(tempguy.family==eeSPINTILE)
14687 {
14688 tempguy.flags |= guy_superman;
14689 tempguy.item_set = 0; // Don't drop items
14690 tempguy.step = 300;
14691 }
14692 }
14693
14694
1/2
✓ Branch 0 taken 58880 times.
✗ Branch 1 not taken.
58880 if(guyversion < 12) // October 2008 - Flashing Bubble, Rope 2, and Ghini 2 fix
14695 {
14696 if(get_bit(deprecated_rules, qr_NOROPE2FLASH_DEP))
14697 {
14698 if(tempguy.family==eeROPE)
14699 {
14700 tempguy.flags2 &= ~guy_flashing;
14701 }
14702 }
14703
14704 if(get_bit(deprecated_rules, qr_NOBUBBLEFLASH_DEP))
14705 {
14706 if(tempguy.family==eeBUBBLE)
14707 {
14708 tempguy.flags2 &= ~guy_flashing;
14709 }
14710 }
14711
14712 if((tempguy.family==eeGHINI)&&(tempguy.misc1))
14713 {
14714 if(get_bit(deprecated_rules, qr_GHINI2BLINK_DEP))
14715 {
14716 tempguy.flags2 |= guy_blinking;
14717 }
14718
14719 if(get_bit(deprecated_rules, qr_PHANTOMGHINI2_DEP))
14720 {
14721 tempguy.flags2 |= guy_transparent;
14722 }
14723 }
14724 }
14725
14726
1/2
✓ Branch 0 taken 58880 times.
✗ Branch 1 not taken.
58880 if(guyversion < 15) // July 2009 - Guy Fire and Fairy fix
14727 {
14728 if(i==gFIRE)
14729 {
14730 tempguy.e_anim = aFLIP;
14731 tempguy.e_frate = 24;
14732 }
14733
14734 if(i==gFAIRY)
14735 {
14736 tempguy.e_anim = a2FRM;
14737 tempguy.e_frate = 16;
14738 }
14739 }
14740
14741
1/2
✓ Branch 0 taken 58880 times.
✗ Branch 1 not taken.
58880 if(guyversion < 16) // November 2009 - Super Enemy Editor part 1
14742 {
14743 if(i==0) Z_message("Updating guys to version 16...\n");
14744
14745 update_guy_1(&tempguy);
14746
14747 if(i==eMPOLSV)
14748 {
14749 tempguy.defense[edefARROW] = edCHINK;
14750 tempguy.defense[edefMAGIC] = ed1HKO;
14751 tempguy.defense[edefREFMAGIC] = ed1HKO;
14752 }
14753 }
14754
14755
1/2
✓ Branch 0 taken 58880 times.
✗ Branch 1 not taken.
58880 if(guyversion < 17) // December 2009
14756 {
14757 if(tempguy.family==eePROJECTILE)
14758 {
14759 tempguy.misc1 = 0;
14760 }
14761 }
14762
14763
1/2
✓ Branch 0 taken 58880 times.
✗ Branch 1 not taken.
58880 if(guyversion < 18) // January 2010
14764 {
14765 bool boss = (tempguy.family == eeAQUA || tempguy.family==eeDONGO || tempguy.family == eeMANHAN || tempguy.family == eeGHOMA || tempguy.family==eeDIG
14766 || tempguy.family == eeGLEEOK || tempguy.family==eePATRA || tempguy.family == eeGANON || tempguy.family==eeMOLD);
14767
14768 tempguy.hitsfx = (boss && tempguy.family != eeMOLD && tempguy.family != eeDONGO && tempguy.family != eeDIG) ? WAV_GASP : 0;
14769 tempguy.deadsfx = (boss && (tempguy.family != eeDIG || tempguy.misc10 == 0)) ? WAV_GASP : WAV_EDEAD;
14770
14771 if(tempguy.family == eeAQUA)
14772 for(int32_t j=0; j<edefLAST; j++) tempguy.defense[j] = default_guys[eRAQUAM].defense[j];
14773 else if(tempguy.family == eeMANHAN)
14774 for(int32_t j=0; j<edefLAST; j++) tempguy.defense[j] = default_guys[eMANHAN].defense[j];
14775 else if(tempguy.family==eePATRA)
14776 for(int32_t j=0; j<edefLAST; j++) tempguy.defense[j] = default_guys[eGLEEOK1].defense[j];
14777 else if(tempguy.family==eeGHOMA)
14778 {
14779 for(int32_t j=0; j<edefLAST; j++)
14780 tempguy.defense[j] = default_guys[eGOHMA1].defense[j];
14781
14782 tempguy.defense[edefARROW] = ((tempguy.misc1==3) ? edCHINKL8 : (tempguy.misc1==2) ? edCHINKL4 : 0);
14783
14784 if(tempguy.misc1==3 && !tempguy.weapon) tempguy.weapon = ewFlame;
14785
14786 tempguy.misc1--;
14787 }
14788 else if(tempguy.family == eeGLEEOK)
14789 {
14790 for(int32_t j=0; j<edefLAST; j++)
14791 tempguy.defense[j] = default_guys[eGLEEOK1].defense[j];
14792
14793 if(tempguy.misc3==1 && !tempguy.weapon) tempguy.weapon = ewFlame;
14794 }
14795 else if(tempguy.family == eeARMOS)
14796 {
14797 tempguy.family=eeWALK;
14798 tempguy.hrate = 0;
14799 tempguy.misc10 = tempguy.misc1;
14800 tempguy.misc1 = tempguy.misc2 = tempguy.misc3 = tempguy.misc4 = tempguy.misc5 = tempguy.misc6 = tempguy.misc7 = tempguy.misc8 = 0;
14801 tempguy.misc9 = e9tARMOS;
14802 }
14803 else if(tempguy.family == eeGHINI && !tempguy.misc1)
14804 {
14805 tempguy.family=eeWALK;
14806 tempguy.hrate = 0;
14807 tempguy.misc1 = tempguy.misc2 = tempguy.misc3 = tempguy.misc4 = tempguy.misc5 = tempguy.misc6 =
14808 tempguy.misc7 = tempguy.misc8 = tempguy.misc9 = tempguy.misc10 = 0;
14809 }
14810
14811 // Spawn animation flags
14812 if(tempguy.family == eeWALK && (tempguy.flags2&cmbflag_armos || tempguy.flags2&cmbflag_ghini))
14813 tempguy.flags |= guy_fadeflicker;
14814 else
14815 tempguy.flags &= 0x0F00000F; // Get rid of the unused flags!
14816 }
14817
14818
1/2
✓ Branch 0 taken 58880 times.
✗ Branch 1 not taken.
58880 if(guyversion < 20) // April 2010
14819 {
14820 if(tempguy.family == eeTRAP)
14821 {
14822 tempguy.misc2 = tempguy.misc10;
14823
14824 if(tempguy.misc10>=1)
14825 {
14826 tempguy.misc1++;
14827 }
14828
14829 tempguy.misc10 = 0;
14830 }
14831
14832 // Bomb Blast fix
14833 if(tempguy.weapon==ewBomb && tempguy.family!=eeROPE && (tempguy.family!=eeWALK || tempguy.misc2 != e2tBOMBCHU))
14834 tempguy.weapon = ewLitBomb;
14835 else if(tempguy.weapon==ewSBomb && tempguy.family!=eeROPE && (tempguy.family!=eeWALK || tempguy.misc2 != e2tBOMBCHU))
14836 tempguy.weapon = ewLitSBomb;
14837 }
14838
14839
1/2
✓ Branch 0 taken 58880 times.
✗ Branch 1 not taken.
58880 if(guyversion < 21) // September 2011
14840 {
14841 if(tempguy.family == eeKEESE || tempguy.family == eeKEESETRIB)
14842 {
14843 if(tempguy.family == eeKEESETRIB)
14844 {
14845 tempguy.family = eeKEESE;
14846 tempguy.misc2 = e2tKEESETRIB;
14847 tempguy.misc1 = 0;
14848 }
14849
14850 tempguy.rate = 2;
14851 tempguy.hrate = 8;
14852 tempguy.homing = 0;
14853 tempguy.step= (tempguy.family == eeKEESE && tempguy.misc1 ? 100:62);
14854 }
14855 else if(tempguy.family == eePEAHAT || tempguy.family==eePATRA)
14856 {
14857 if(tempguy.family == eePEAHAT)
14858 {
14859 tempguy.rate = 4;
14860 tempguy.step = 62;
14861 }
14862 else
14863 tempguy.step = 25;
14864
14865 tempguy.hrate = 8;
14866 tempguy.homing = 0;
14867 }
14868 else if(tempguy.family == eeDIG || tempguy.family == eeMANHAN)
14869 {
14870 if(tempguy.family == eeMANHAN)
14871 tempguy.step=50;
14872
14873 tempguy.hrate = 16;
14874 tempguy.homing = 0;
14875 }
14876 else if(tempguy.family == eeGLEEOK)
14877 {
14878 tempguy.rate = 2;
14879 tempguy.homing = 0;
14880 tempguy.hrate = 9;
14881 tempguy.step=89;
14882 }
14883 else if(tempguy.family == eeGHINI)
14884 {
14885 tempguy.rate = 4;
14886 tempguy.hrate = 12;
14887 tempguy.step=62;
14888 tempguy.homing = 0;
14889 }
14890
14891 // Bigdig random rate fix
14892 if(tempguy.family==eeDIG && tempguy.misc10==1)
14893 {
14894 tempguy.rate = 2;
14895 }
14896 }
14897
14898
1/2
✓ Branch 0 taken 58880 times.
✗ Branch 1 not taken.
58880 if(guyversion < 24) // November 2012
14899 {
14900 if(tempguy.family==eeLANM)
14901 tempguy.misc3 = 1;
14902 else if(tempguy.family==eeMOLD)
14903 tempguy.misc2 = 0;
14904 }
14905
14906
2/2
✓ Branch 0 taken 19456 times.
✓ Branch 1 taken 39424 times.
58880 if(guyversion < 33) //Whistle defence did not exist before this version of 2.54. -Z
14907 {
14908
2/2
✓ Branch 0 taken 660 times.
✓ Branch 1 taken 38764 times.
39424 if(tempguy.family!=eeDIG)
14909 {
14910 38764 tempguy.defense[edefWhistle] = edIGNORE; //Might need to be ignore, universally.
14911 38764 }
14912
14913 39424 }
14914 // does not seem to solve the issue!
14915
1/2
✓ Branch 0 taken 58880 times.
✗ Branch 1 not taken.
58880 if ( Header->zelda_version <= 0x210 )
14916 {
14917 al_trace("Detected version %d for dodongo patch.\n",Header->zelda_version);
14918 if ( tempguy.family == eeDONGO )
14919 {
14920 tempguy.deadsfx = 15; //In 2.10 and earlier, Dodongos used this as their death sound.
14921 }
14922 }
14923
14924
2/2
✓ Branch 0 taken 19456 times.
✓ Branch 1 taken 39424 times.
58880 if(guyversion >= 42)
14925 {
14926
2/2
✓ Branch 0 taken 18432 times.
✓ Branch 1 taken 1024 times.
19456 if(guyversion >= 47)
14927 {
14928
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if(!p_igetl(&(tempguy.moveflags),f))
14929 {
14930 return qe_invalid;
14931 }
14932 18432 }
14933 else
14934 {
14935 byte fl;
14936
1/2
✓ Branch 0 taken 1024 times.
✗ Branch 1 not taken.
1024 if(!p_getc(&fl,f))
14937 {
14938 return qe_invalid;
14939 }
14940 1024 tempguy.moveflags = fl;
14941 }
14942 19456 }
14943 else
14944 {
14945
7/8
✓ Branch 0 taken 446 times.
✓ Branch 1 taken 30899 times.
✓ Branch 2 taken 1202 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 518 times.
✓ Branch 5 taken 278 times.
✓ Branch 6 taken 241 times.
✓ Branch 7 taken 5840 times.
39424 switch(tempguy.family)
14946 {
14947 //No gravity; floats over pits
14948 case eeTEK: case eePEAHAT: case eeROCK: case eeTRAP:
14949 case eePROJECTILE: case eeSPINTILE: case eeKEESE: case eeFIRE:
14950 //Special (bosses, etc)
14951 case eeFAIRY: case eeGUY: case eeNONE: case eeZORA:
14952 case eeAQUA: case eeDIG: case eeGHOMA: case eeGANON:
14953 case eePATRA: case eeGLEEOK: case eeMOLD: case eeMANHAN:
14954 30899 tempguy.moveflags = FLAG_CAN_PITWALK;
14955 30899 break;
14956 //No gravity, but falls in pits
14957 case eeLEV:
14958 518 tempguy.moveflags = FLAG_CAN_PITFALL;
14959 518 break;
14960 //Bosses that respect pits
14961 case eeDONGO:
14962 278 tempguy.moveflags = FLAG_OBEYS_GRAV;
14963 278 break;
14964 case eeLANM:
14965 241 tempguy.moveflags = 0;
14966 241 break;
14967 //Gravity, floats over pits
14968 case eeWIZZ: case eeWALLM: case eeGHINI:
14969 1202 tempguy.moveflags = FLAG_OBEYS_GRAV | FLAG_CAN_PITWALK;
14970 1202 break;
14971 //Gravity and falls in pits
14972 case eeWALK:
14973
4/4
✓ Branch 0 taken 5519 times.
✓ Branch 1 taken 321 times.
✓ Branch 2 taken 280 times.
✓ Branch 3 taken 5239 times.
5840 if (tempguy.misc9==e9tPOLSVOICE||tempguy.misc9==e9tVIRE)
14974 601 break;
14975 [[fallthrough]];
14976 case eeOTHER:
14977 case eeSCRIPT01: case eeSCRIPT02: case eeSCRIPT03: case eeSCRIPT04: case eeSCRIPT05:
14978 case eeSCRIPT06: case eeSCRIPT07: case eeSCRIPT08: case eeSCRIPT09: case eeSCRIPT10:
14979 case eeSCRIPT11: case eeSCRIPT12: case eeSCRIPT13: case eeSCRIPT14: case eeSCRIPT15:
14980 case eeSCRIPT16: case eeSCRIPT17: case eeSCRIPT18: case eeSCRIPT19: case eeSCRIPT20:
14981 case eeFFRIENDLY01: case eeFFRIENDLY02: case eeFFRIENDLY03: case eeFFRIENDLY04: case eeFFRIENDLY05:
14982 case eeFFRIENDLY06: case eeFFRIENDLY07: case eeFFRIENDLY08: case eeFFRIENDLY09: case eeFFRIENDLY10:
14983 5685 tempguy.moveflags = FLAG_OBEYS_GRAV | FLAG_CAN_PITFALL;
14984 5685 }
14985 }
14986
2/2
✓ Branch 0 taken 19456 times.
✓ Branch 1 taken 39424 times.
58880 if(guyversion < 43)
14987 {
14988
2/2
✓ Branch 0 taken 32101 times.
✓ Branch 1 taken 7323 times.
39424 switch(tempguy.family)
14989 {
14990 //No gravity; floats over pits
14991 case eeTEK: case eePEAHAT: case eeROCK: case eeTRAP:
14992 case eePROJECTILE: case eeSPINTILE: case eeKEESE: case eeFIRE:
14993 //Special (bosses, etc)
14994 case eeFAIRY: case eeGUY: case eeNONE: case eeZORA:
14995 case eeAQUA: case eeDIG: case eeGHOMA: case eeGANON:
14996 case eePATRA: case eeGLEEOK: case eeMOLD: case eeMANHAN:
14997 case eeWIZZ: case eeWALLM: case eeGHINI:
14998 //Gravity, floats over pits
14999 32101 tempguy.moveflags |= FLAG_CAN_WATERWALK;
15000 32101 tempguy.moveflags |= FLAG_CAN_PITWALK;
15001 32101 break;
15002 }
15003 39424 }
15004
2/2
✓ Branch 0 taken 19456 times.
✓ Branch 1 taken 39424 times.
58880 if (guyversion < 44)
15005 {
15006
2/2
✓ Branch 0 taken 39054 times.
✓ Branch 1 taken 370 times.
39424 if ( tempguy.family == eeGHOMA )
15007 {
15008 370 tempguy.flags |= guy_fadeinstant;
15009 370 }
15010 39424 }
15011
2/2
✓ Branch 0 taken 19456 times.
✓ Branch 1 taken 39424 times.
58880 if (guyversion > 44)
15012 {
15013
1/2
✓ Branch 0 taken 19456 times.
✗ Branch 1 not taken.
19456 if(!p_getc(&(tempguy.spr_shadow),f))
15014 {
15015 return qe_invalid;
15016 }
15017
1/2
✓ Branch 0 taken 19456 times.
✗ Branch 1 not taken.
19456 if(!p_getc(&(tempguy.spr_death),f))
15018 {
15019 return qe_invalid;
15020 }
15021
1/2
✓ Branch 0 taken 19456 times.
✗ Branch 1 not taken.
19456 if(!p_getc(&(tempguy.spr_spawn),f))
15022 {
15023 return qe_invalid;
15024 }
15025 19456 }
15026 else
15027 {
15028
2/2
✓ Branch 0 taken 39271 times.
✓ Branch 1 taken 153 times.
39424 tempguy.spr_shadow = (tempguy.family==eeROCK && tempguy.misc10==1) ? iwLargeShadow : iwShadow;
15029 39424 tempguy.spr_death = iwDeath;
15030 39424 tempguy.spr_spawn = iwSpawn;
15031 }
15032
15033
2/2
✓ Branch 0 taken 19456 times.
✓ Branch 1 taken 39424 times.
58880 if(guyversion < 46)
15034 {
15035
4/4
✓ Branch 0 taken 5840 times.
✓ Branch 1 taken 33584 times.
✓ Branch 2 taken 5519 times.
✓ Branch 3 taken 321 times.
39424 if(tempguy.family == eeWALK && tempguy.misc9 == e9tPOLSVOICE)
15036 {
15037 321 tempguy.moveflags |= FLAG_CAN_WATERWALK;
15038 321 }
15039 39424 }
15040
15041
1/2
✓ Branch 0 taken 58880 times.
✗ Branch 1 not taken.
58880 if(loading_tileset_flags & TILESET_CLEARSCRIPTS)
15042 {
15043 tempguy.script = 0;
15044 for(int q = 0; q < 8; ++q)
15045 tempguy.initD[q] = 0;
15046 }
15047 58880 guysbuf[i] = tempguy;
15048 58880 }
15049 115 }
15050
15051 115 return 0;
15052 131 }
15053
15054 void update_guy_1(guydata *tempguy) // November 2009
15055 {
15056 bool doesntcount = false;
15057 tempguy->flags &= ~weak_arrow; // Formerly 'weak to arrow' which wasn't implemented
15058
15059 switch(tempguy->family)
15060 {
15061 case 1: //eeWALK
15062 switch(tempguy->misc10)
15063 {
15064 case 0: //Stalfos
15065 if(tempguy->misc1==1) // Fires four projectiles at once
15066 tempguy->misc1=4;
15067
15068 break;
15069
15070 case 1: //Darknut
15071 goto darknuts;
15072 break;
15073 }
15074
15075 tempguy->misc10 = 0;
15076 break;
15077
15078 case 2: //eeSHOOT
15079 tempguy->family = eeWALK;
15080
15081 switch(tempguy->misc10)
15082 {
15083 case 0: //Octorok
15084 if(tempguy->misc1==1||tempguy->misc1==2)
15085 {
15086 tempguy->misc1=e1tFIREOCTO;
15087 tempguy->misc2=e2tFIREOCTO;
15088 }
15089 else tempguy->misc1 = 0;
15090
15091 tempguy->misc6=tempguy->misc4;
15092 tempguy->misc4=tempguy->misc3;
15093 tempguy->misc3=0;
15094 break;
15095
15096 case 1: // Moblin
15097 tempguy->misc1 = 0;
15098 break;
15099
15100 case 2: //Lynel
15101 tempguy->misc6=tempguy->misc1+1;
15102 tempguy->misc1=0;
15103 break;
15104
15105 case 3: //Stalfos 2
15106 if(tempguy->misc1==1) // Fires four projectiles at once
15107 tempguy->misc1=e1t4SHOTS;
15108 else tempguy->misc1 = 0;
15109
15110 break;
15111
15112 case 4: //Darknut 5
15113 darknuts:
15114 tempguy->defense[edefFIRE] = edIGNORE;
15115 tempguy->defense[edefBRANG] = edSTUNORCHINK;
15116 tempguy->defense[edefHOOKSHOT] = 0;
15117 tempguy->defense[edefARROW] = tempguy->defense[edefBYRNA] = tempguy->defense[edefREFROCK] =
15118 tempguy->defense[edefMAGIC] = tempguy->defense[edefSTOMP] = edCHINK;
15119
15120 if(tempguy->misc1==1)
15121 tempguy->misc1=2;
15122 else if(tempguy->misc1==2)
15123 {
15124 tempguy->misc4=tempguy->misc3;
15125 tempguy->misc3=tempguy->misc2;
15126 tempguy->misc2=e2tSPLIT;
15127 tempguy->misc1 = 0;
15128 }
15129 else tempguy->misc1 = 0;
15130
15131 tempguy->flags |= inv_front;
15132
15133 if(get_bit(deprecated_rules,qr_BRKBLSHLDS_DEP))
15134 tempguy->flags |= guy_bkshield;
15135
15136 break;
15137 }
15138
15139 tempguy->misc10 = 0;
15140 break;
15141
15142 /*
15143 case 9: //eeARMOS
15144 tempguy->family = eeWALK;
15145 break;
15146 */
15147 case 11: //eeGEL
15148 case 33: //eeGELTRIB
15149 if(tempguy->family==33)
15150 {
15151 tempguy->misc4 = 1;
15152
15153 if(get_bit(deprecated_rules, qr_OLDTRIBBLES_DEP)) //Old Tribbles
15154 tempguy->misc3 = tempguy->misc2;
15155
15156 tempguy->misc2 = e2tTRIBBLE;
15157 }
15158 else
15159 {
15160 tempguy->misc4 = 0;
15161 tempguy->misc3 = 0;
15162 tempguy->misc2 = 0;
15163 }
15164
15165 tempguy->family = eeWALK;
15166
15167 if(tempguy->misc1)
15168 {
15169 tempguy->misc1=1;
15170 tempguy->weapon = ewFireTrail;
15171 }
15172
15173 break;
15174
15175 case 34: //eeZOLTRIB
15176 case 12: //eeZOL
15177 tempguy->misc4=tempguy->misc3;
15178 tempguy->misc3=tempguy->misc2;
15179 tempguy->family = eeWALK;
15180 tempguy->misc2=e2tSPLITHIT;
15181
15182 if(tempguy->misc1)
15183 {
15184 tempguy->misc1=1;
15185 tempguy->weapon = ewFireTrail;
15186 }
15187
15188 break;
15189
15190 case 13: //eeROPE
15191 tempguy->family = eeWALK;
15192 tempguy->misc9 = e9tROPE;
15193
15194 if(tempguy->misc1)
15195 {
15196 tempguy->misc4 = tempguy->misc3;
15197 tempguy->misc3 = tempguy->misc2;
15198 tempguy->misc2 = e2tBOMBCHU;
15199 }
15200
15201 tempguy->misc1 = 0;
15202 break;
15203
15204 case 14: //eeGORIYA
15205 tempguy->family = eeWALK;
15206
15207 if(tempguy->misc1!=2) tempguy->misc1 = 0;
15208
15209 break;
15210
15211 case 17: //eeBUBBLE
15212 tempguy->family = eeWALK;
15213 tempguy->misc8 = tempguy->misc2;
15214 tempguy->misc7 = tempguy->misc1 + 1;
15215 tempguy->misc1 = tempguy->misc2 = 0;
15216
15217 //fallthrogh
15218 case eeTRAP:
15219 case eeROCK:
15220 doesntcount = true;
15221 break;
15222
15223 case 35: //eeVIRETRIB
15224 case 18: //eeVIRE
15225 tempguy->family = eeWALK;
15226 tempguy->misc4=tempguy->misc3;
15227 tempguy->misc3=tempguy->misc2;
15228 tempguy->misc2=e2tSPLITHIT;
15229 tempguy->misc9=e9tVIRE;
15230 break;
15231
15232 case 19: //eeLIKE
15233 tempguy->family = eeWALK;
15234 tempguy->misc7 = e7tEATITEMS;
15235 tempguy->misc8=95;
15236 break;
15237
15238 case 20: //eePOLSV
15239 tempguy->defense[edefBRANG] = edSTUNORCHINK;
15240 tempguy->defense[edefBOMB] = tempguy->defense[edefSBOMB] = tempguy->defense[edefFIRE] = edIGNORE;
15241 tempguy->defense[edefMAGIC] = tempguy->defense[edefBYRNA] = edCHINK;
15242 tempguy->defense[edefARROW] = ed1HKO;
15243 tempguy->defense[edefHOOKSHOT] = edSTUNONLY;
15244 tempguy->family = eeWALK;
15245 tempguy->misc9 = e9tPOLSVOICE;
15246 tempguy->rate = 4;
15247 tempguy->homing = 32;
15248 tempguy->hrate = 10;
15249 tempguy->grumble = 0;
15250 break;
15251
15252 case eeWIZZ:
15253 if(tempguy->misc4)
15254 {
15255 for(int32_t i=0; i < edefLAST; i++)
15256 tempguy->defense[i] = (i != edefREFBEAM && i != edefREFMAGIC && i != edefQUAKE) ? edIGNORE : 0;
15257 }
15258 else
15259 {
15260 tempguy->defense[edefBRANG] = edSTUNORCHINK;
15261 tempguy->defense[edefMAGIC] = edCHINK;
15262 tempguy->defense[edefHOOKSHOT] = edSTUNONLY;
15263 tempguy->defense[edefARROW] = tempguy->defense[edefFIRE] =
15264 tempguy->defense[edefWAND] = tempguy->defense[edefBYRNA] = edIGNORE;
15265 }
15266
15267 break;
15268
15269 case eePEAHAT:
15270 tempguy->flags &= ~(guy_superman|guy_sbombonly);
15271
15272 if(!(tempguy->flags & guy_bhit))
15273 tempguy->defense[edefBRANG] = edSTUNONLY;
15274
15275 break;
15276
15277 case eeLEV:
15278 tempguy->defense[edefSTOMP] = edCHINK;
15279 break;
15280 }
15281
15282 // Old flags
15283 if(tempguy->flags & guy_superman)
15284 {
15285 for(int32_t i = 0; i < edefLAST; i++)
15286 if(!(i==edefSBOMB && (tempguy->flags & guy_sbombonly)))
15287 tempguy->defense[i] = (i==edefBRANG && tempguy->defense[i] != edIGNORE
15288 && tempguy->family != eeROCK && tempguy->family != eeTRAP
15289 && tempguy->family != eePROJECTILE) ? edSTUNORIGNORE : edIGNORE;
15290 }
15291
15292 tempguy->flags &= ~(guy_superman|guy_sbombonly);
15293
15294 if(doesntcount)
15295 tempguy->flags |= (guy_doesntcount);
15296 }
15297
15298
15299 247176 int32_t readmapscreen_old(PACKFILE *f, zquestheader *Header, mapscr *temp_mapscr, word version)
15300 {
15301 byte tempbyte, padding;
15302 int32_t extras, secretcombos;
15303 //al_trace("readmapscreen Header->zelda_version: %x\n",Header->zelda_version);
15304
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 247176 times.
247176 if(!p_getc(&(temp_mapscr->valid),f))
15305 {
15306 return qe_invalid;
15307 }
15308
15309
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 247176 times.
247176 if(!p_getc(&(temp_mapscr->guy),f))
15310 return qe_invalid;
15311 247176 temp_mapscr->guytile = -1; //signal to use default guy values
15312
2/2
✓ Branch 0 taken 246700 times.
✓ Branch 1 taken 476 times.
247176 SETFLAG(temp_mapscr->roomflags,RFL_ALWAYS_GUY,temp_mapscr->guy==gFAIRY);
15313
4/4
✓ Branch 0 taken 476 times.
✓ Branch 1 taken 246700 times.
✓ Branch 2 taken 23 times.
✓ Branch 3 taken 453 times.
247176 SETFLAG(temp_mapscr->roomflags,RFL_GUYFIRES,temp_mapscr->guy!=gFAIRY || !get_qr(qr_NOFAIRYGUYFIRES));
15314
15315
3/6
✓ Branch 0 taken 240312 times.
✓ Branch 1 taken 6864 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 240312 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<146)))
15316 {
15317
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6864 times.
6864 if(!p_getc(&tempbyte,f))
15318 {
15319 return qe_invalid;
15320 }
15321
15322 6864 temp_mapscr->str=tempbyte;
15323 6864 }
15324 else
15325 {
15326
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 240312 times.
240312 if(!p_igetw(&(temp_mapscr->str),f))
15327 {
15328 return qe_invalid;
15329 }
15330 }
15331
15332
1/2
✓ Branch 0 taken 247176 times.
✗ Branch 1 not taken.
247176 if(!p_getc(&(temp_mapscr->room),f))
15333 {
15334 return qe_invalid;
15335 }
15336
15337
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 247176 times.
247176 if(!p_getc(&(temp_mapscr->item),f))
15338 {
15339 return qe_invalid;
15340 }
15341
15342
3/6
✓ Branch 0 taken 153408 times.
✓ Branch 1 taken 93768 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 153408 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if(Header->zelda_version < 0x211 || (Header->zelda_version == 0x211 && Header->build < 14))
15343 {
15344 93768 temp_mapscr->hasitem = (temp_mapscr->item != 0) ? 1 : 0;
15345 93768 }
15346 else
15347 {
15348
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 153408 times.
153408 if(!p_getc(&(temp_mapscr->hasitem),f))
15349 return qe_invalid;
15350 }
15351
15352
2/4
✓ Branch 0 taken 240312 times.
✓ Branch 1 taken 6864 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
247176 if((Header->zelda_version < 0x192)||
15353
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 240312 times.
240312 ((Header->zelda_version == 0x192)&&(Header->build<154)))
15354 {
15355
1/2
✓ Branch 0 taken 6864 times.
✗ Branch 1 not taken.
6864 if(!p_getc(&tempbyte,f))
15356 {
15357 return qe_invalid;
15358 }
15359 6864 }
15360
15361
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 247176 times.
247176 if(!p_getc(&(temp_mapscr->tilewarptype[0]),f))
15362 {
15363 return qe_invalid;
15364 }
15365
15366
2/2
✓ Branch 0 taken 240312 times.
✓ Branch 1 taken 6864 times.
247176 if(Header->zelda_version < 0x193)
15367 {
15368
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6864 times.
6864 if(!p_getc(&tempbyte,f))
15369 {
15370 return qe_invalid;
15371 }
15372 6864 }
15373
15374
3/6
✓ Branch 0 taken 93768 times.
✓ Branch 1 taken 153408 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 93768 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15375 {
15376
2/2
✓ Branch 0 taken 460224 times.
✓ Branch 1 taken 153408 times.
613632 for(int32_t i=1; i<4; i++)
15377 {
15378
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 460224 times.
460224 if(!p_getc(&(temp_mapscr->tilewarptype[i]),f))
15379 {
15380 return qe_invalid;
15381 }
15382 460224 }
15383 153408 }
15384 else
15385 {
15386 93768 temp_mapscr->tilewarptype[1]=0;
15387 93768 temp_mapscr->tilewarptype[2]=0;
15388 93768 temp_mapscr->tilewarptype[3]=0;
15389 }
15390
15391
3/6
✓ Branch 0 taken 6864 times.
✓ Branch 1 taken 240312 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6864 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>153)))
15392 {
15393
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 240312 times.
240312 if(!p_igetw(&(temp_mapscr->door_combo_set),f))
15394 {
15395 return qe_invalid;
15396 }
15397 240312 }
15398
15399
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 247176 times.
247176 if(!p_getc(&(temp_mapscr->warpreturnx[0]),f))
15400 {
15401 return qe_invalid;
15402 }
15403
15404 247176 temp_mapscr->warpreturnx[1]=0;
15405 247176 temp_mapscr->warpreturnx[2]=0;
15406 247176 temp_mapscr->warpreturnx[3]=0;
15407
15408
3/6
✓ Branch 0 taken 93768 times.
✓ Branch 1 taken 153408 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 93768 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15409 {
15410
2/2
✓ Branch 0 taken 460224 times.
✓ Branch 1 taken 153408 times.
613632 for(int32_t i=1; i<4; i++)
15411 {
15412
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 460224 times.
460224 if(!p_getc(&(temp_mapscr->warpreturnx[i]),f))
15413 {
15414 return qe_invalid;
15415 }
15416 460224 }
15417 153408 }
15418
15419
1/2
✓ Branch 0 taken 247176 times.
✗ Branch 1 not taken.
247176 if(!p_getc(&(temp_mapscr->warpreturny[0]),f))
15420 {
15421 return qe_invalid;
15422 }
15423
15424 247176 temp_mapscr->warpreturny[1]=0;
15425 247176 temp_mapscr->warpreturny[2]=0;
15426 247176 temp_mapscr->warpreturny[3]=0;
15427
15428
3/6
✓ Branch 0 taken 93768 times.
✓ Branch 1 taken 153408 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 93768 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15429 {
15430
2/2
✓ Branch 0 taken 460224 times.
✓ Branch 1 taken 153408 times.
613632 for(int32_t i=1; i<4; i++)
15431 {
15432
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 460224 times.
460224 if(!p_getc(&(temp_mapscr->warpreturny[i]),f))
15433 {
15434 return qe_invalid;
15435 }
15436 460224 }
15437
15438
1/2
✓ Branch 0 taken 153408 times.
✗ Branch 1 not taken.
153408 if(version>=18)
15439 {
15440
1/2
✓ Branch 0 taken 153408 times.
✗ Branch 1 not taken.
153408 if(!p_igetw(&temp_mapscr->warpreturnc,f))
15441 {
15442 return qe_invalid;
15443 }
15444 153408 }
15445 else
15446 {
15447 byte temp;
15448
15449 if(!p_getc(&temp,f))
15450 {
15451 return qe_invalid;
15452 }
15453
15454 temp_mapscr->warpreturnc=temp<<8|temp;
15455 }
15456 153408 }
15457
15458
1/2
✓ Branch 0 taken 247176 times.
✗ Branch 1 not taken.
247176 if(!p_getc(&(temp_mapscr->stairx),f))
15459
15460 {
15461 return qe_invalid;
15462 }
15463
15464
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 247176 times.
247176 if(!p_getc(&(temp_mapscr->stairy),f))
15465 {
15466 return qe_invalid;
15467 }
15468
15469
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 247176 times.
247176 if(!p_getc(&(temp_mapscr->itemx),f))
15470 {
15471 return qe_invalid;
15472 }
15473
15474
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 247176 times.
247176 if(!p_getc(&(temp_mapscr->itemy),f))
15475 {
15476 return qe_invalid;
15477 }
15478
15479
2/2
✓ Branch 0 taken 153408 times.
✓ Branch 1 taken 93768 times.
247176 if(version > 15) // February 2009
15480 {
15481
1/2
✓ Branch 0 taken 153408 times.
✗ Branch 1 not taken.
153408 if(!p_igetw(&(temp_mapscr->color),f))
15482 {
15483 return qe_invalid;
15484 }
15485 153408 }
15486 else
15487 {
15488
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 93768 times.
93768 if(!p_getc(& tempbyte,f))
15489 {
15490 return qe_invalid;
15491 }
15492
15493 93768 temp_mapscr->color = (word) tempbyte;
15494 }
15495
15496
1/2
✓ Branch 0 taken 247176 times.
✗ Branch 1 not taken.
247176 if(!p_getc(&(temp_mapscr->enemyflags),f))
15497 {
15498 return qe_invalid;
15499 }
15500
15501
2/2
✓ Branch 0 taken 988704 times.
✓ Branch 1 taken 247176 times.
1235880 for(int32_t k=0; k<4; k++)
15502 {
15503
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 988704 times.
988704 if(!p_getc(&(temp_mapscr->door[k]),f))
15504 {
15505 return qe_invalid;
15506
15507 }
15508 988704 }
15509
15510
2/2
✓ Branch 0 taken 93768 times.
✓ Branch 1 taken 153408 times.
247176 if(version <= 11)
15511 {
15512
1/2
✓ Branch 0 taken 93768 times.
✗ Branch 1 not taken.
93768 if(!p_getc(&(tempbyte),f))
15513 {
15514 return qe_invalid;
15515 }
15516
15517 93768 temp_mapscr->tilewarpdmap[0]=(word)tempbyte;
15518
15519
2/6
✓ Branch 0 taken 93768 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 93768 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
93768 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15520 {
15521 for(int32_t i=1; i<4; i++)
15522 {
15523 if(!p_getc(&(tempbyte),f))
15524 {
15525 return qe_invalid;
15526 }
15527
15528 temp_mapscr->tilewarpdmap[i]=(word)tempbyte;
15529 }
15530 }
15531 else
15532 {
15533 93768 temp_mapscr->tilewarpdmap[1]=0;
15534 93768 temp_mapscr->tilewarpdmap[2]=0;
15535 93768 temp_mapscr->tilewarpdmap[3]=0;
15536 }
15537 93768 }
15538 else
15539 {
15540
2/2
✓ Branch 0 taken 613632 times.
✓ Branch 1 taken 153408 times.
767040 for(int32_t i=0; i<4; i++)
15541 {
15542
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 613632 times.
613632 if(!p_igetw(&(temp_mapscr->tilewarpdmap[i]),f))
15543 {
15544 return qe_invalid;
15545 }
15546 613632 }
15547 }
15548
15549
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 247176 times.
247176 if(!p_getc(&(temp_mapscr->tilewarpscr[0]),f))
15550 {
15551 return qe_invalid;
15552 }
15553
15554
3/6
✓ Branch 0 taken 93768 times.
✓ Branch 1 taken 153408 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 93768 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15555 {
15556
2/2
✓ Branch 0 taken 460224 times.
✓ Branch 1 taken 153408 times.
613632 for(int32_t i=1; i<4; i++)
15557 {
15558
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 460224 times.
460224 if(!p_getc(&(temp_mapscr->tilewarpscr[i]),f))
15559 {
15560 return qe_invalid;
15561 }
15562 460224 }
15563 153408 }
15564 else
15565 {
15566 93768 temp_mapscr->tilewarpscr[1]=0;
15567 93768 temp_mapscr->tilewarpscr[2]=0;
15568 93768 temp_mapscr->tilewarpscr[3]=0;
15569 }
15570
15571
2/2
✓ Branch 0 taken 153408 times.
✓ Branch 1 taken 93768 times.
247176 if(version >= 15)
15572 {
15573
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 153408 times.
153408 if(!p_getc(&(temp_mapscr->tilewarpoverlayflags),f))
15574 {
15575 return qe_invalid;
15576 }
15577 153408 }
15578 else
15579 {
15580 93768 temp_mapscr->tilewarpoverlayflags=0;
15581 }
15582
15583
1/2
✓ Branch 0 taken 247176 times.
✗ Branch 1 not taken.
247176 if(!p_getc(&(temp_mapscr->exitdir),f))
15584 {
15585 return qe_invalid;
15586 }
15587
15588
2/2
✓ Branch 0 taken 240312 times.
✓ Branch 1 taken 6864 times.
247176 if(Header->zelda_version < 0x193)
15589 {
15590
1/2
✓ Branch 0 taken 6864 times.
✗ Branch 1 not taken.
6864 if(!p_getc(&tempbyte,f))
15591 {
15592 return qe_invalid;
15593 }
15594
15595 6864 }
15596
15597
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 247176 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version == 0x192)&&(Header->build>145)&&(Header->build<154))
15598 {
15599 if(!p_getc(&padding,f))
15600 {
15601 return qe_invalid;
15602 }
15603 }
15604
15605
2/2
✓ Branch 0 taken 2471760 times.
✓ Branch 1 taken 247176 times.
2718936 for(int32_t k=0; k<10; k++)
15606 {
15607 /*
15608 if (!temp_mapscr->enemy[k])
15609 {
15610 continue;
15611 }
15612 */
15613
3/6
✓ Branch 0 taken 2403120 times.
✓ Branch 1 taken 68640 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2403120 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2471760 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<10)))
15614 {
15615
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 68640 times.
68640 if(!p_getc(&tempbyte,f))
15616 {
15617 return qe_invalid;
15618 }
15619
15620 68640 temp_mapscr->enemy[k]=tempbyte;
15621 68640 }
15622 else
15623 {
15624
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2403120 times.
2403120 if(!p_igetw(&(temp_mapscr->enemy[k]),f))
15625 {
15626 return qe_invalid;
15627 }
15628 }
15629
15630
3/6
✓ Branch 0 taken 2403120 times.
✓ Branch 1 taken 68640 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2403120 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2471760 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<108)))
15631 {
15632 //using enumerations here is dangerous
15633 //very easy to break old quests -DD
15634
2/2
✓ Branch 0 taken 788 times.
✓ Branch 1 taken 67852 times.
68640 if(temp_mapscr->enemy[k]>=57) //old eGOHMA1
15635 {
15636 788 temp_mapscr->enemy[k]+=5;
15637 788 }
15638
2/2
✓ Branch 0 taken 67812 times.
✓ Branch 1 taken 40 times.
67852 else if(temp_mapscr->enemy[k]>=52) //old eGLEEOK2
15639 {
15640 40 temp_mapscr->enemy[k]+=1;
15641 40 }
15642 68640 }
15643
15644
2/2
✓ Branch 0 taken 1534080 times.
✓ Branch 1 taken 937680 times.
2471760 if(version < 9)
15645 {
15646
2/2
✓ Branch 0 taken 856505 times.
✓ Branch 1 taken 81175 times.
937680 if(temp_mapscr->enemy[k]>0)
15647 {
15648 81175 temp_mapscr->enemy[k]+=10;
15649 81175 }
15650 937680 }
15651 //don't read in any invalid data
15652
2/2
✓ Branch 0 taken 2471670 times.
✓ Branch 1 taken 90 times.
2471760 if ( ((unsigned)temp_mapscr->enemy[k]) > MAXGUYS )
15653 {
15654 90 al_trace("Tried to read an invalid enemy ID (%d) for tmpscr->enemy[%d]. This has been cleared to 0.\n", temp_mapscr->enemy[k], k);
15655 90 temp_mapscr->enemy[k] = 0;
15656 90 }
15657 2471760 }
15658
15659
1/2
✓ Branch 0 taken 247176 times.
✗ Branch 1 not taken.
247176 if(!p_getc(&(temp_mapscr->pattern),f))
15660 {
15661 return qe_invalid;
15662 }
15663
15664
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 247176 times.
247176 if(!p_getc(&(temp_mapscr->sidewarptype[0]),f))
15665 {
15666 return qe_invalid;
15667 }
15668
15669
3/6
✓ Branch 0 taken 93768 times.
✓ Branch 1 taken 153408 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 93768 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15670 {
15671
2/2
✓ Branch 0 taken 460224 times.
✓ Branch 1 taken 153408 times.
613632 for(int32_t i=1; i<4; i++)
15672 {
15673
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 460224 times.
460224 if(!p_getc(&(temp_mapscr->sidewarptype[i]),f))
15674 {
15675 return qe_invalid;
15676 }
15677 460224 }
15678 153408 }
15679 else
15680 {
15681 93768 temp_mapscr->sidewarptype[1]=0;
15682 93768 temp_mapscr->sidewarptype[2]=0;
15683 93768 temp_mapscr->sidewarptype[3]=0;
15684 }
15685
15686
2/2
✓ Branch 0 taken 153408 times.
✓ Branch 1 taken 93768 times.
247176 if(version >= 15)
15687 {
15688
1/2
✓ Branch 0 taken 153408 times.
✗ Branch 1 not taken.
153408 if(!p_getc(&(temp_mapscr->sidewarpoverlayflags),f))
15689 {
15690 return qe_invalid;
15691 }
15692 153408 }
15693 else
15694 {
15695 93768 temp_mapscr->sidewarpoverlayflags=0;
15696 }
15697
15698
1/2
✓ Branch 0 taken 247176 times.
✗ Branch 1 not taken.
247176 if(!p_getc(&(temp_mapscr->warparrivalx),f))
15699 {
15700 return qe_invalid;
15701 }
15702
15703
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 247176 times.
247176 if(!p_getc(&(temp_mapscr->warparrivaly),f))
15704 {
15705 return qe_invalid;
15706 }
15707
15708
2/2
✓ Branch 0 taken 988704 times.
✓ Branch 1 taken 247176 times.
1235880 for(int32_t k=0; k<4; k++)
15709 {
15710
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 988704 times.
988704 if(!p_getc(&(temp_mapscr->path[k]),f))
15711 {
15712 return qe_invalid;
15713 }
15714 988704 }
15715
15716
1/2
✓ Branch 0 taken 247176 times.
✗ Branch 1 not taken.
247176 if(!p_getc(&(temp_mapscr->sidewarpscr[0]),f))
15717 {
15718 return qe_invalid;
15719 }
15720
15721
3/6
✓ Branch 0 taken 93768 times.
✓ Branch 1 taken 153408 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 93768 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15722 {
15723
2/2
✓ Branch 0 taken 153408 times.
✓ Branch 1 taken 460224 times.
613632 for(int32_t i=1; i<4; i++)
15724 {
15725
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 460224 times.
460224 if(!p_getc(&(temp_mapscr->sidewarpscr[i]),f))
15726 {
15727 return qe_invalid;
15728 }
15729 460224 }
15730 153408 }
15731 else
15732 {
15733 93768 temp_mapscr->sidewarpscr[1]=0;
15734 93768 temp_mapscr->sidewarpscr[2]=0;
15735 93768 temp_mapscr->sidewarpscr[3]=0;
15736 }
15737
15738
2/2
✓ Branch 0 taken 93768 times.
✓ Branch 1 taken 153408 times.
247176 if(version <= 11)
15739 {
15740
1/2
✓ Branch 0 taken 93768 times.
✗ Branch 1 not taken.
93768 if(!p_getc(&(tempbyte),f))
15741 {
15742 return qe_invalid;
15743 }
15744
15745 93768 temp_mapscr->sidewarpdmap[0]=(word)tempbyte;
15746
15747
2/6
✓ Branch 0 taken 93768 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 93768 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
93768 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15748 {
15749 for(int32_t i=1; i<4; i++)
15750 {
15751 if(!p_getc(&(tempbyte),f))
15752 {
15753 return qe_invalid;
15754 }
15755
15756 temp_mapscr->sidewarpdmap[i]=(word)tempbyte;
15757 }
15758 }
15759 else
15760 {
15761 93768 temp_mapscr->sidewarpdmap[1]=0;
15762 93768 temp_mapscr->sidewarpdmap[2]=0;
15763 93768 temp_mapscr->sidewarpdmap[3]=0;
15764 }
15765 93768 }
15766 else
15767 {
15768
2/2
✓ Branch 0 taken 613632 times.
✓ Branch 1 taken 153408 times.
767040 for(int32_t i=0; i<4; i++)
15769 {
15770
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 613632 times.
613632 if(!p_igetw(&(temp_mapscr->sidewarpdmap[i]),f))
15771 {
15772 return qe_invalid;
15773 }
15774 613632 }
15775 }
15776
15777
3/6
✓ Branch 0 taken 93768 times.
✓ Branch 1 taken 153408 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 93768 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15778 {
15779
1/2
✓ Branch 0 taken 153408 times.
✗ Branch 1 not taken.
153408 if(!p_getc(&(temp_mapscr->sidewarpindex),f))
15780 {
15781 return qe_invalid;
15782 }
15783 153408 }
15784 93768 else temp_mapscr->sidewarpindex = 0;
15785
15786
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 247176 times.
247176 if(!p_igetw(&(temp_mapscr->undercombo),f))
15787 {
15788 return qe_invalid;
15789 }
15790
15791
2/2
✓ Branch 0 taken 240312 times.
✓ Branch 1 taken 6864 times.
247176 if(Header->zelda_version < 0x193)
15792 {
15793
1/2
✓ Branch 0 taken 6864 times.
✗ Branch 1 not taken.
6864 if(!p_getc(&(temp_mapscr->old_cpage),f))
15794 {
15795 return qe_invalid;
15796 }
15797 6864 }
15798
15799
1/2
✓ Branch 0 taken 247176 times.
✗ Branch 1 not taken.
247176 if(!p_getc(&(temp_mapscr->undercset),f)) //recalculated for older quests
15800 {
15801 return qe_invalid;
15802 }
15803
15804
1/2
✓ Branch 0 taken 247176 times.
✗ Branch 1 not taken.
247176 if(!p_igetw(&(temp_mapscr->catchall),f))
15805 {
15806 return qe_invalid;
15807 }
15808
15809
1/2
✓ Branch 0 taken 247176 times.
✗ Branch 1 not taken.
247176 if(!p_getc(&(temp_mapscr->flags),f))
15810 {
15811 return qe_invalid;
15812 }
15813
15814
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 247176 times.
247176 if(!p_getc(&(temp_mapscr->flags2),f))
15815 {
15816 return qe_invalid;
15817 }
15818
15819
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 247176 times.
247176 if(!p_getc(&(temp_mapscr->flags3),f))
15820 {
15821 return qe_invalid;
15822 }
15823
15824
3/6
✓ Branch 0 taken 93768 times.
✓ Branch 1 taken 153408 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 93768 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>1)))
15825 //if (version>2)
15826 {
15827
1/2
✓ Branch 0 taken 153408 times.
✗ Branch 1 not taken.
153408 if(!p_getc(&(temp_mapscr->flags4),f))
15828 {
15829 return qe_invalid;
15830 }
15831 153408 }
15832
15833
3/6
✓ Branch 0 taken 93768 times.
✓ Branch 1 taken 153408 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 93768 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15834 {
15835
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 153408 times.
153408 if(!p_getc(&(temp_mapscr->flags5),f))
15836 {
15837 return qe_invalid;
15838 }
15839
15840
1/2
✓ Branch 0 taken 153408 times.
✗ Branch 1 not taken.
153408 if(!p_igetw(&(temp_mapscr->noreset),f))
15841 {
15842 return qe_invalid;
15843 }
15844
15845
1/2
✓ Branch 0 taken 153408 times.
✗ Branch 1 not taken.
153408 if(!p_igetw(&(temp_mapscr->nocarry),f))
15846 {
15847 return qe_invalid;
15848 }
15849
15850
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 153408 times.
153408 if(temp_mapscr->flags5&32)
15851 {
15852 temp_mapscr->flags5 &= ~32;
15853 temp_mapscr->noreset |= 48;
15854 }
15855
15856
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 153408 times.
153408 if(version<8)
15857 {
15858 if(temp_mapscr->noreset&1)
15859 {
15860 temp_mapscr->noreset|=8192;
15861 }
15862
15863 if(temp_mapscr->nocarry&1)
15864 {
15865 temp_mapscr->nocarry|=8192;
15866 temp_mapscr->nocarry&=~1;
15867 }
15868 }
15869 153408 }
15870 else
15871 {
15872 93768 temp_mapscr->flags5 = 0;
15873 93768 temp_mapscr->noreset = 0;
15874 93768 temp_mapscr->nocarry = 0;
15875 }
15876
15877
3/6
✓ Branch 0 taken 93768 times.
✓ Branch 1 taken 153408 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 93768 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>9)))
15878 {
15879
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 153408 times.
153408 if(!p_getc(&(temp_mapscr->flags6),f))
15880 {
15881 return qe_invalid;
15882 }
15883 153408 }
15884
15885
2/2
✓ Branch 0 taken 153408 times.
✓ Branch 1 taken 93768 times.
247176 if(version>5)
15886 {
15887
1/2
✓ Branch 0 taken 153408 times.
✗ Branch 1 not taken.
153408 if(!p_getc(&(temp_mapscr->flags7),f))
15888 {
15889 return qe_invalid;
15890 }
15891
15892
1/2
✓ Branch 0 taken 153408 times.
✗ Branch 1 not taken.
153408 if(!p_getc(&(temp_mapscr->flags8),f))
15893 {
15894 return qe_invalid;
15895 }
15896
15897
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 153408 times.
153408 if(!p_getc(&(temp_mapscr->flags9),f))
15898 {
15899 return qe_invalid;
15900 }
15901
15902
1/2
✓ Branch 0 taken 153408 times.
✗ Branch 1 not taken.
153408 if(!p_getc(&(temp_mapscr->flags10),f))
15903 {
15904 return qe_invalid;
15905 }
15906
15907
1/2
✓ Branch 0 taken 153408 times.
✗ Branch 1 not taken.
153408 if(!p_getc(&(temp_mapscr->csensitive),f))
15908 {
15909 return qe_invalid;
15910 }
15911 153408 }
15912 else
15913 {
15914 93768 temp_mapscr->csensitive=1;
15915 }
15916
15917
2/2
✓ Branch 0 taken 93768 times.
✓ Branch 1 taken 153408 times.
247176 if(version<14) // August 2007: screen SFX added
15918 {
15919
2/2
✓ Branch 0 taken 93668 times.
✓ Branch 1 taken 100 times.
93768 if(temp_mapscr->flags&8) //fROAR
15920 {
15921 100 temp_mapscr->bosssfx=
15922
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 91 times.
100 (temp_mapscr->flags3&2) ? WAV_DODONGO : // fDODONGO
15923 91 (temp_mapscr->flags2&32) ? WAV_VADER : // fVADER
15924 WAV_ROAR;
15925 100 }
15926
15927
2/2
✓ Branch 0 taken 91 times.
✓ Branch 1 taken 93677 times.
93768 if(temp_mapscr->flags&128) //fSEA
15928 {
15929 91 temp_mapscr->oceansfx=WAV_SEA;
15930 91 }
15931
15932 93768 temp_mapscr->secretsfx = (temp_mapscr->flags3&64) //fNOSECRETSOUND
15933 ? 0 : WAV_SECRET;
15934
15935 93768 temp_mapscr->flags3 &= ~66; //64|2
15936 93768 temp_mapscr->flags2 &= ~32;
15937 93768 temp_mapscr->flags &= ~136; // 128|8
15938 93768 }
15939 else
15940 {
15941
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 153408 times.
153408 if(!p_getc(&(temp_mapscr->oceansfx),f))
15942 {
15943 return qe_invalid;
15944 }
15945
15946
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 153408 times.
153408 if(!p_getc(&(temp_mapscr->bosssfx),f))
15947 {
15948 return qe_invalid;
15949 }
15950
15951
1/2
✓ Branch 0 taken 153408 times.
✗ Branch 1 not taken.
153408 if(!p_getc(&(temp_mapscr->secretsfx),f))
15952 {
15953 return qe_invalid;
15954 }
15955 }
15956
15957
2/2
✓ Branch 0 taken 93768 times.
✓ Branch 1 taken 153408 times.
247176 if(version<15) // October 2007: another SFX
15958 {
15959 93768 temp_mapscr->holdupsfx=WAV_PICKUP;
15960 93768 }
15961 else
15962 {
15963
1/2
✓ Branch 0 taken 153408 times.
✗ Branch 1 not taken.
153408 if(!p_getc(&(temp_mapscr->holdupsfx),f))
15964 {
15965 return qe_invalid;
15966 }
15967 }
15968
15969
15970
3/6
✓ Branch 0 taken 6864 times.
✓ Branch 1 taken 240312 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6864 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>97)))
15971 {
15972
2/2
✓ Branch 0 taken 1441872 times.
✓ Branch 1 taken 240312 times.
1682184 for(int32_t k=0; k<6; k++)
15973 {
15974
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1441872 times.
1441872 if(!p_getc(&(temp_mapscr->layermap[k]),f))
15975 {
15976 return qe_invalid;
15977 }
15978 1441872 }
15979
15980
2/2
✓ Branch 0 taken 240312 times.
✓ Branch 1 taken 1441872 times.
1682184 for(int32_t k=0; k<6; k++)
15981 {
15982
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1441872 times.
1441872 if(!p_getc(&(temp_mapscr->layerscreen[k]),f))
15983 {
15984 return qe_invalid;
15985 }
15986 1441872 }
15987 240312 }
15988
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 6864 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
6864 else if((Header->zelda_version == 0x192)&&(Header->build>23)&&(Header->build<98))
15989 {
15990 if(!p_getc(&(temp_mapscr->layermap[2]),f))
15991 {
15992 return qe_invalid;
15993 }
15994
15995 if(!p_getc(&(temp_mapscr->layerscreen[2]),f))
15996 {
15997 return qe_invalid;
15998 }
15999
16000 if(!p_getc(&(temp_mapscr->layermap[4]),f))
16001 {
16002 return qe_invalid;
16003 }
16004
16005 if(!p_getc(&(temp_mapscr->layerscreen[4]),f))
16006
16007 {
16008 return qe_invalid;
16009 }
16010 }
16011
16012
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 247176 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
247176 if((Header->zelda_version == 0x192)&&(Header->build>149))
16013 {
16014 for(int32_t k=0; k<6; k++)
16015 {
16016 if(!p_getc(&tempbyte,f)) //layerxsize
16017 {
16018 return qe_invalid;
16019 }
16020 }
16021
16022 for(int32_t k=0; k<6; k++)
16023 {
16024 if(!p_getc(&tempbyte,f)) //layerxspeed
16025 {
16026 return qe_invalid;
16027 }
16028 }
16029
16030 for(int32_t k=0; k<6; k++)
16031 {
16032 if(!p_getc(&tempbyte,f)) //layerxdelay
16033 {
16034 return qe_invalid;
16035 }
16036 }
16037
16038 for(int32_t k=0; k<6; k++)
16039 {
16040 if(!p_getc(&tempbyte,f)) //layerysize
16041 {
16042 return qe_invalid;
16043 }
16044 }
16045
16046 for(int32_t k=0; k<6; k++)
16047 {
16048 if(!p_getc(&tempbyte,f)) //layeryspeed
16049 {
16050 return qe_invalid;
16051 }
16052 }
16053
16054 for(int32_t k=0; k<6; k++)
16055 {
16056 if(!p_getc(&tempbyte,f)) //layerydelay
16057 {
16058 return qe_invalid;
16059 }
16060 }
16061 }
16062
16063
3/6
✓ Branch 0 taken 6864 times.
✓ Branch 1 taken 240312 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6864 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>149)))
16064 {
16065
2/2
✓ Branch 0 taken 1441872 times.
✓ Branch 1 taken 240312 times.
1682184 for(int32_t k=0; k<6; k++)
16066 {
16067
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1441872 times.
1441872 if(!p_getc(&(temp_mapscr->layeropacity[k]),f))
16068 {
16069 return qe_invalid;
16070 }
16071 1441872 }
16072 240312 }
16073
16074
3/6
✓ Branch 0 taken 6864 times.
✓ Branch 1 taken 240312 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6864 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>153)))
16075 {
16076
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 240312 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
240312 if((Header->zelda_version == 0x192)&&(Header->build>153))
16077 {
16078 if(!p_getc(&padding,f))
16079 {
16080 return qe_invalid;
16081 }
16082 }
16083
16084
1/2
✓ Branch 0 taken 240312 times.
✗ Branch 1 not taken.
240312 if(!p_igetw(&(temp_mapscr->timedwarptics),f))
16085 {
16086 return qe_invalid;
16087 }
16088 240312 }
16089
16090
3/6
✓ Branch 0 taken 240312 times.
✓ Branch 1 taken 6864 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 240312 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<24)))
16091 {
16092 6864 extras=15;
16093 6864 }
16094
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 240312 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
240312 else if(((Header->zelda_version == 0x192)&&(Header->build<98)))
16095 {
16096 extras=11;
16097 }
16098
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 240312 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
240312 else if((Header->zelda_version == 0x192)&&(Header->build<150))
16099 {
16100 extras=32;
16101 }
16102
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 240312 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
240312 else if((Header->zelda_version == 0x192)&&(Header->build<154))
16103 {
16104 extras=64;
16105 }
16106
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 240312 times.
240312 else if(Header->zelda_version < 0x193)
16107 {
16108 extras=62;
16109 }
16110 else
16111
16112 {
16113 240312 extras=0;
16114 }
16115
16116
2/2
✓ Branch 0 taken 102960 times.
✓ Branch 1 taken 247176 times.
350136 for(int32_t k=0; k<extras; k++)
16117 {
16118
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 102960 times.
102960 if(!p_getc(&tempbyte,f)) //extra[k]
16119 {
16120 return qe_invalid;
16121 }
16122 102960 }
16123
16124
3/6
✓ Branch 0 taken 93768 times.
✓ Branch 1 taken 153408 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 93768 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>2)))
16125 //if (version>3)
16126 {
16127
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 153408 times.
153408 if(!p_getc(&(temp_mapscr->nextmap),f))
16128 {
16129 return qe_invalid;
16130 }
16131
16132
1/2
✓ Branch 0 taken 153408 times.
✗ Branch 1 not taken.
153408 if(!p_getc(&(temp_mapscr->nextscr),f))
16133 {
16134 return qe_invalid;
16135 }
16136 153408 }
16137 else
16138 {
16139 93768 temp_mapscr->nextmap=0;
16140 93768 temp_mapscr->nextscr=0;
16141 }
16142
16143
3/6
✓ Branch 0 taken 240312 times.
✓ Branch 1 taken 6864 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 240312 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<137)))
16144 {
16145 6864 secretcombos=20;
16146 6864 }
16147
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 240312 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
240312 else if((Header->zelda_version == 0x192)&&(Header->build<154))
16148 {
16149 secretcombos=256;
16150 }
16151 else
16152 {
16153 240312 secretcombos=128;
16154 }
16155
16156
3/6
✓ Branch 0 taken 240312 times.
✓ Branch 1 taken 6864 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 240312 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<154)))
16157 {
16158
2/2
✓ Branch 0 taken 137280 times.
✓ Branch 1 taken 6864 times.
144144 for(int32_t k=0; k<secretcombos; k++)
16159 {
16160
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 137280 times.
137280 if(!p_getc(&tempbyte,f))
16161 {
16162 return qe_invalid;
16163 }
16164
16165
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 137280 times.
137280 if(k<128)
16166 {
16167 137280 temp_mapscr->secretcombo[k]=tempbyte;
16168 137280 }
16169 137280 }
16170 6864 }
16171 else
16172 {
16173
2/2
✓ Branch 0 taken 30759936 times.
✓ Branch 1 taken 240312 times.
31000248 for(int32_t k=0; k<128; k++)
16174 {
16175
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30759936 times.
30759936 if(!p_igetw(&(temp_mapscr->secretcombo[k]),f))
16176 {
16177 return qe_invalid;
16178 }
16179
16180 30759936 }
16181 }
16182
16183
3/6
✓ Branch 0 taken 6864 times.
✓ Branch 1 taken 240312 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6864 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>153)))
16184 {
16185
2/2
✓ Branch 0 taken 30759936 times.
✓ Branch 1 taken 240312 times.
31000248 for(int32_t k=0; k<128; k++)
16186 {
16187
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30759936 times.
30759936 if(!p_getc(&(temp_mapscr->secretcset[k]),f))
16188 {
16189 return qe_invalid;
16190 }
16191 30759936 }
16192
16193
2/2
✓ Branch 0 taken 30759936 times.
✓ Branch 1 taken 240312 times.
31000248 for(int32_t k=0; k<128; k++)
16194 {
16195
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30759936 times.
30759936 if(!p_getc(&(temp_mapscr->secretflag[k]),f))
16196 {
16197 return qe_invalid;
16198 }
16199 30759936 }
16200 240312 }
16201
16202
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 247176 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version == 0x192)&&(Header->build>97)&&(Header->build<154))
16203 {
16204 if(!p_getc(&padding,f))
16205 {
16206 return qe_invalid;
16207 }
16208 }
16209
16210
2/2
✓ Branch 0 taken 43502976 times.
✓ Branch 1 taken 247176 times.
43750152 for(int32_t k=0; k<176; k++)
16211 {
16212
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 43502976 times.
43502976 if(!p_igetw(&(temp_mapscr->data[k]),f))
16213 {
16214 return qe_invalid;
16215 }
16216 43502976 }
16217
16218
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 247176 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version == 0x192)&&(Header->build>20)&&(Header->build<24))
16219 {
16220 if(!p_getc(&padding,f))
16221 {
16222 return qe_invalid;
16223 }
16224
16225 if(!p_getc(&padding,f))
16226 {
16227 return qe_invalid;
16228 }
16229 }
16230
16231
3/6
✓ Branch 0 taken 6864 times.
✓ Branch 1 taken 240312 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6864 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>20)))
16232 {
16233
2/2
✓ Branch 0 taken 42294912 times.
✓ Branch 1 taken 240312 times.
42535224 for(int32_t k=0; k<176; k++)
16234 {
16235
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 42294912 times.
42294912 if(!p_getc(&(temp_mapscr->sflag[k]),f))
16236 {
16237 return qe_invalid;
16238 }
16239
16240
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 42294912 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
42294912 if((Header->zelda_version == 0x192)&&(Header->build<24))
16241 {
16242 if(!p_getc(&tempbyte,f))
16243 {
16244 return qe_invalid;
16245 }
16246
16247 if(!p_getc(&tempbyte,f))
16248 {
16249 return qe_invalid;
16250 }
16251
16252 if(!p_getc(&tempbyte,f))
16253 {
16254 return qe_invalid;
16255 }
16256 }
16257 42294912 }
16258 240312 }
16259
16260
3/6
✓ Branch 0 taken 6864 times.
✓ Branch 1 taken 240312 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6864 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>97)))
16261 {
16262
2/2
✓ Branch 0 taken 240312 times.
✓ Branch 1 taken 42294912 times.
42535224 for(int32_t k=0; k<176; k++)
16263 {
16264
16265
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 42294912 times.
42294912 if(!p_getc(&(temp_mapscr->cset[k]),f))
16266 {
16267 return qe_invalid;
16268 }
16269 42294912 }
16270 240312 }
16271
16272
3/6
✓ Branch 0 taken 240312 times.
✓ Branch 1 taken 6864 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 240312 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<154)))
16273 {
16274 6864 temp_mapscr->undercset=(temp_mapscr->undercombo>>8)&7;
16275 6864 temp_mapscr->undercombo=(temp_mapscr->undercombo&0xFF)+(temp_mapscr->old_cpage<<8);
16276 6864 }
16277
16278
3/6
✓ Branch 0 taken 240312 times.
✓ Branch 1 taken 6864 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 240312 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<137)))
16279 {
16280 6864 temp_mapscr->secretcombo[sSBOMB]=temp_mapscr->secretcombo[sBOMB];
16281 6864 temp_mapscr->secretcombo[sRCANDLE]=temp_mapscr->secretcombo[sBCANDLE];
16282 6864 temp_mapscr->secretcombo[sWANDFIRE]=temp_mapscr->secretcombo[sBCANDLE];
16283 6864 temp_mapscr->secretcombo[sDIVINEFIRE]=temp_mapscr->secretcombo[sBCANDLE];
16284 6864 temp_mapscr->secretcombo[sSARROW]=temp_mapscr->secretcombo[sARROW];
16285 6864 temp_mapscr->secretcombo[sGARROW]=temp_mapscr->secretcombo[sARROW];
16286 6864 }
16287
16288
3/6
✓ Branch 0 taken 240312 times.
✓ Branch 1 taken 6864 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 240312 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<154)))
16289 {
16290
2/2
✓ Branch 0 taken 1208064 times.
✓ Branch 1 taken 6864 times.
1214928 for(int32_t k=0; k<176; k++)
16291 {
16292
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1208064 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1208064 if((Header->zelda_version == 0x192)&&(Header->build>149))
16293 {
16294 if((Header->zelda_version == 0x192)&&(Header->build!=153))
16295 {
16296 temp_mapscr->cset[k]=((temp_mapscr->data[k]>>8)&7);
16297 }
16298 }
16299 else
16300 {
16301
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1208064 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1208064 if((Header->zelda_version < 0x192)||
16302 ((Header->zelda_version == 0x192)&&(Header->build<21)))
16303 {
16304 1208064 temp_mapscr->sflag[k]=(temp_mapscr->data[k]>>11);
16305 1208064 }
16306
16307 1208064 temp_mapscr->cset[k]=((temp_mapscr->data[k]>>8)&7);
16308 }
16309
16310 1208064 temp_mapscr->data[k]=(temp_mapscr->data[k]&0xFF)+(temp_mapscr->old_cpage<<8);
16311 1208064 }
16312 6864 }
16313
16314 /*if(version>12)
16315 {
16316 if(!p_getc(&(temp_mapscr->scrWidth),f))
16317 {
16318 return qe_invalid;
16319 }
16320 if(!p_getc(&(temp_mapscr->scrHeight),f))
16321 {
16322 return qe_invalid;
16323 }
16324 }*/
16325
16326
2/2
✓ Branch 0 taken 153408 times.
✓ Branch 1 taken 93768 times.
247176 if(version>4)
16327 {
16328
1/2
✓ Branch 0 taken 153408 times.
✗ Branch 1 not taken.
153408 if(!p_igetw(&(temp_mapscr->screen_midi),f))
16329 {
16330 return qe_invalid;
16331 }
16332 153408 }
16333 else
16334 {
16335 93768 temp_mapscr->screen_midi = -1;
16336 }
16337
16338
2/2
✓ Branch 0 taken 153408 times.
✓ Branch 1 taken 93768 times.
247176 if(version>=17)
16339 {
16340
1/2
✓ Branch 0 taken 153408 times.
✗ Branch 1 not taken.
153408 if(!p_getc(&(temp_mapscr->lens_layer),f))
16341 {
16342 return qe_invalid;
16343 }
16344 153408 }
16345 else
16346 {
16347 93768 temp_mapscr->lens_layer = llNORMAL;
16348 }
16349
16350
2/2
✓ Branch 0 taken 93768 times.
✓ Branch 1 taken 153408 times.
247176 if(version>6)
16351 {
16352 dword bits;
16353
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 153408 times.
153408 if(!p_igetl(&bits,f))
16354 {
16355 return qe_invalid;
16356 }
16357
16358 int32_t m;
16359 float tempfloat;
16360 word tempw;
16361 153408 temp_mapscr->ffcCountMarkDirty();
16362
16363
2/2
✓ Branch 0 taken 153408 times.
✓ Branch 1 taken 4909056 times.
5062464 for(m=0; m<32; m++)
16364 {
16365 4909056 ffcdata& tempffc = temp_mapscr->ffcs[m];
16366 4909056 tempffc.clear();
16367
2/2
✓ Branch 0 taken 4886067 times.
✓ Branch 1 taken 22989 times.
4909056 if((bits>>m)&1)
16368 {
16369
1/2
✓ Branch 0 taken 22989 times.
✗ Branch 1 not taken.
22989 if(!p_igetw(&tempw,f))
16370 {
16371 return qe_invalid;
16372 }
16373 22989 tempffc.data = tempw;
16374
16375
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22989 times.
22989 if(!p_getc(&(tempffc.cset),f))
16376 {
16377 return qe_invalid;
16378 }
16379
16380
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22989 times.
22989 if(!p_igetw(&(tempffc.delay),f))
16381 {
16382 return qe_invalid;
16383 }
16384
16385
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22989 times.
22989 if(version < 9)
16386 {
16387 if(!p_igetf_DO_NOT_USE(&tempfloat,f))
16388 {
16389 return qe_invalid;
16390 }
16391
16392 tempffc.x=zslongToFix(int32_t(tempfloat*10000));
16393
16394 if(!p_igetf_DO_NOT_USE(&tempfloat,f))
16395 {
16396 return qe_invalid;
16397 }
16398
16399 tempffc.y=zslongToFix(int32_t(tempfloat*10000));
16400
16401 if(!p_igetf_DO_NOT_USE(&tempfloat,f))
16402 {
16403 return qe_invalid;
16404 }
16405
16406 tempffc.vx=zslongToFix(int32_t(tempfloat*10000));
16407
16408 if(!p_igetf_DO_NOT_USE(&tempfloat,f))
16409 {
16410 return qe_invalid;
16411 }
16412
16413 tempffc.vy=zslongToFix(int32_t(tempfloat*10000));
16414
16415 if(!p_igetf_DO_NOT_USE(&tempfloat,f))
16416 {
16417 return qe_invalid;
16418 }
16419
16420 tempffc.ax=zslongToFix(int32_t(tempfloat*10000));
16421
16422 if(!p_igetf_DO_NOT_USE(&tempfloat,f))
16423 {
16424 return qe_invalid;
16425 }
16426
16427 tempffc.ay=zslongToFix(int32_t(tempfloat*10000));
16428 }
16429 else
16430 {
16431
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22989 times.
22989 if(!p_igetzf(&(tempffc.x),f))
16432 {
16433 return qe_invalid;
16434 }
16435
16436
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22989 times.
22989 if(!p_igetzf(&(tempffc.y),f))
16437 {
16438 return qe_invalid;
16439 }
16440
16441
1/2
✓ Branch 0 taken 22989 times.
✗ Branch 1 not taken.
22989 if(!p_igetzf(&(tempffc.vx),f))
16442 {
16443 return qe_invalid;
16444 }
16445
16446
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22989 times.
22989 if(!p_igetzf(&(tempffc.vy),f))
16447 {
16448 return qe_invalid;
16449 }
16450
16451
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22989 times.
22989 if(!p_igetzf(&(tempffc.ax),f))
16452 {
16453 return qe_invalid;
16454 }
16455
16456
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22989 times.
22989 if(!p_igetzf(&(tempffc.ay),f))
16457 {
16458 return qe_invalid;
16459 }
16460 }
16461
16462
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22989 times.
22989 if(!p_getc(&(tempffc.link),f))
16463 {
16464 return qe_invalid;
16465 }
16466
16467
1/2
✓ Branch 0 taken 22989 times.
✗ Branch 1 not taken.
22989 if(version>7)
16468 {
16469
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22989 times.
22989 if(!p_getc(&tempbyte,f))
16470 {
16471 return qe_invalid;
16472 }
16473
16474 22989 tempffc.hit_width = (tempbyte&0x3F)+1;
16475 22989 tempffc.txsz = (tempbyte>>6)+1;
16476
16477
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22989 times.
22989 if(!p_getc(&tempbyte,f))
16478 {
16479 return qe_invalid;
16480 }
16481
16482 22989 tempffc.hit_height = (tempbyte&0x3F)+1;
16483 22989 tempffc.tysz = (tempbyte>>6)+1;
16484
16485
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22989 times.
22989 if(!p_igetl(&(tempffc.flags),f))
16486 {
16487 return qe_invalid;
16488 }
16489 22989 }
16490 else
16491 {
16492 tempffc.hit_width=16;
16493 tempffc.hit_height=16;
16494 tempffc.txsz=1;
16495 tempffc.tysz=1;
16496 tempffc.flags=0;
16497 }
16498
16499 22989 tempffc.updateSolid();
16500
16501
16502
4/6
✓ Branch 0 taken 22989 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 20969 times.
✓ Branch 3 taken 2020 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 20969 times.
22989 if(Header->zelda_version == 0x211 || (Header->zelda_version == 0x250 && Header->build<20))
16503 {
16504 tempffc.flags|=ffIGNOREHOLDUP;
16505 }
16506
16507
1/2
✓ Branch 0 taken 22989 times.
✗ Branch 1 not taken.
22989 if(version>9)
16508 {
16509
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22989 times.
22989 if(!p_igetw(&(tempffc.script),f))
16510 {
16511 return qe_invalid;
16512 }
16513 22989 }
16514 else
16515 {
16516 tempffc.script=0;
16517 }
16518
16519
1/2
✓ Branch 0 taken 22989 times.
✗ Branch 1 not taken.
22989 if(version>10)
16520 {
16521
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22989 times.
22989 if(!p_igetl(&(tempffc.initd[0]),f))
16522 {
16523 return qe_invalid;
16524 }
16525
16526
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22989 times.
22989 if(!p_igetl(&(tempffc.initd[1]),f))
16527 {
16528 return qe_invalid;
16529 }
16530
16531
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22989 times.
22989 if(!p_igetl(&(tempffc.initd[2]),f))
16532 {
16533 return qe_invalid;
16534 }
16535
16536
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22989 times.
22989 if(!p_igetl(&(tempffc.initd[3]),f))
16537 {
16538 return qe_invalid;
16539 }
16540
16541
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22989 times.
22989 if(!p_igetl(&(tempffc.initd[4]),f))
16542 {
16543 return qe_invalid;
16544 }
16545
16546
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22989 times.
22989 if(!p_igetl(&(tempffc.initd[5]),f))
16547 {
16548 return qe_invalid;
16549 }
16550
16551
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22989 times.
22989 if(!p_igetl(&(tempffc.initd[6]),f))
16552 {
16553 return qe_invalid;
16554 }
16555
16556
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22989 times.
22989 if(!p_igetl(&(tempffc.initd[7]),f))
16557 {
16558 return qe_invalid;
16559 }
16560
16561
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22989 times.
22989 if(!p_getc(&(tempbyte),f))
16562 {
16563 return qe_invalid;
16564 }
16565
16566 22989 tempffc.inita[0]=tempbyte*10000;
16567
16568
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22989 times.
22989 if(!p_getc(&(tempbyte),f))
16569 {
16570 return qe_invalid;
16571 }
16572
16573 22989 tempffc.inita[1]=tempbyte*10000;
16574 22989 }
16575 else
16576 {
16577 tempffc.inita[0] = 10000;
16578 tempffc.inita[1] = 10000;
16579 }
16580
16581
1/2
✓ Branch 0 taken 22989 times.
✗ Branch 1 not taken.
22989 if(loading_tileset_flags & TILESET_CLEARSCRIPTS)
16582 {
16583 tempffc.script = 0;
16584 for(int q = 0; q < 8; ++q)
16585 tempffc.initd[q] = 0;
16586 }
16587
1/2
✓ Branch 0 taken 22989 times.
✗ Branch 1 not taken.
22989 if(version <= 11)
16588 {
16589 fixffcs=true;
16590 }
16591 22989 }
16592 4909056 }
16593
2/2
✓ Branch 0 taken 14727168 times.
✓ Branch 1 taken 153408 times.
14880576 for(m = 32; m < MAXFFCS; ++m)
16594 {
16595 14727168 temp_mapscr->ffcs[m].clear();
16596 14727168 }
16597 153408 }
16598
16599 //add in the new whistle flags
16600
2/2
✓ Branch 0 taken 153408 times.
✓ Branch 1 taken 93768 times.
247176 if(version<13)
16601 {
16602
2/2
✓ Branch 0 taken 19 times.
✓ Branch 1 taken 93749 times.
93768 if(temp_mapscr->flags & fWHISTLE)
16603 {
16604 19 temp_mapscr->flags7 |= (fWHISTLEPAL | fWHISTLEWATER);
16605 19 }
16606 93768 }
16607
16608 //2.55 starts here
16609
3/4
✓ Branch 0 taken 13736 times.
✓ Branch 1 taken 233440 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 13736 times.
247176 if ( version >= 19 && Header->zelda_version > 0x253 )
16610 {
16611
2/2
✓ Branch 0 taken 137360 times.
✓ Branch 1 taken 13736 times.
151096 for ( int32_t q = 0; q < 10; q++ )
16612 {
16613
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 137360 times.
137360 if(!p_igetl(&(temp_mapscr->npcstrings[q]),f))
16614 {
16615 return qe_invalid;
16616 }
16617 137360 }
16618
2/2
✓ Branch 0 taken 137360 times.
✓ Branch 1 taken 13736 times.
151096 for ( int32_t q = 0; q < 10; q++ )
16619 {
16620
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 137360 times.
137360 if(!p_igetw(&(temp_mapscr->new_items[q]),f))
16621 {
16622 return qe_invalid;
16623 }
16624 137360 }
16625
2/2
✓ Branch 0 taken 137360 times.
✓ Branch 1 taken 13736 times.
151096 for ( int32_t q = 0; q < 10; q++ )
16626 {
16627
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 137360 times.
137360 if(!p_igetw(&(temp_mapscr->new_item_x[q]),f))
16628 {
16629 return qe_invalid;
16630 }
16631 137360 }
16632
2/2
✓ Branch 0 taken 13736 times.
✓ Branch 1 taken 137360 times.
151096 for ( int32_t q = 0; q < 10; q++ )
16633 {
16634
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 137360 times.
137360 if(!p_igetw(&(temp_mapscr->new_item_y[q]),f))
16635 {
16636 return qe_invalid;
16637 }
16638 137360 }
16639 13736 }
16640
3/4
✓ Branch 0 taken 233440 times.
✓ Branch 1 taken 13736 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 233440 times.
247176 if ( version < 19 && Header->zelda_version > 0x253 )
16641 {
16642 for ( int32_t q = 0; q < 10; q++ )
16643 {
16644 temp_mapscr->npcstrings[q] = 0;
16645 temp_mapscr->new_items[q] = 0;
16646 temp_mapscr->new_item_x[q] = 0;
16647 temp_mapscr->new_item_y[q] = 0;
16648 }
16649 }
16650
3/4
✓ Branch 0 taken 13736 times.
✓ Branch 1 taken 233440 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 13736 times.
247176 if ( version >= 20 && Header->zelda_version > 0x253 )
16651 {
16652
1/2
✓ Branch 0 taken 13736 times.
✗ Branch 1 not taken.
13736 if(!p_igetw(&(temp_mapscr->script),f))
16653 {
16654 return qe_invalid;
16655 }
16656
2/2
✓ Branch 0 taken 109888 times.
✓ Branch 1 taken 13736 times.
123624 for ( int32_t q = 0; q < 8; q++)
16657 {
16658
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 109888 times.
109888 if(!p_igetl(&(temp_mapscr->screeninitd[q]),f))
16659 {
16660 return qe_invalid;
16661 }
16662 109888 }
16663 13736 }
16664
2/2
✓ Branch 0 taken 13736 times.
✓ Branch 1 taken 233440 times.
247176 if ( version < 20 )
16665 {
16666 233440 temp_mapscr->script = 0;
16667
2/2
✓ Branch 0 taken 1867520 times.
✓ Branch 1 taken 233440 times.
2100960 for ( int32_t q = 0; q < 8; q++) temp_mapscr->screeninitd[q] = 0;
16668 233440 }
16669
3/4
✓ Branch 0 taken 13736 times.
✓ Branch 1 taken 233440 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 13736 times.
247176 if ( version >= 21 && Header->zelda_version > 0x253 )
16670 {
16671
1/2
✓ Branch 0 taken 13736 times.
✗ Branch 1 not taken.
13736 if(!p_getc(&(temp_mapscr->preloadscript),f))
16672 {
16673 return qe_invalid;
16674 }
16675 13736 }
16676
2/2
✓ Branch 0 taken 233440 times.
✓ Branch 1 taken 13736 times.
247176 if ( version < 21 )
16677 {
16678 233440 temp_mapscr->preloadscript = 0;
16679 233440 }
16680 //all builds with version > 20 need this. -Z
16681
16682
3/4
✓ Branch 0 taken 13736 times.
✓ Branch 1 taken 233440 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 13736 times.
247176 if ( version >= 22 && Header->zelda_version > 0x253 ) //26th June, 2019; Layer Visibility
16683 {
16684
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13736 times.
13736 if(!p_getc(&(temp_mapscr->hidelayers ),f))
16685 {
16686 return qe_invalid;
16687 }
16688
1/2
✓ Branch 0 taken 13736 times.
✗ Branch 1 not taken.
13736 if(!p_getc(&(temp_mapscr->hidescriptlayers ),f))
16689 {
16690 return qe_invalid;
16691 }
16692 13736 }
16693
2/2
✓ Branch 0 taken 233440 times.
✓ Branch 1 taken 13736 times.
247176 if ( version < 22 )
16694 {
16695 233440 temp_mapscr->hidelayers = 0;
16696 233440 temp_mapscr->hidescriptlayers = 0;
16697 233440 }
16698
16699 //Dodongos in 2.10 used the boss roar, not the dodongo sound. -Z
16700 //May be any version before 2.11. -Z
16701 /* --not the roar, the HIT SFX
16702 if ( Header->zelda_version <= 0x210 )
16703 {
16704 if ( temp_mapscr->bosssfx == WAV_DODONGO )
16705 {
16706 temp_mapscr->bosssfx = WAV_ROAR;
16707 }
16708 }
16709 */
16710
2/2
✓ Branch 0 taken 988704 times.
✓ Branch 1 taken 247176 times.
1235880 for(int32_t k=0; k<4; k++)
16711 {
16712
1/2
✓ Branch 0 taken 988704 times.
✗ Branch 1 not taken.
988704 if(temp_mapscr->door[k] == dNONE)
16713 temp_mapscr->door[k] = dWALL;
16714 988704 }
16715
16716 247176 return 0;
16717 247176 }
16718 264176 int32_t readmapscreen(PACKFILE *f, zquestheader *Header, mapscr *temp_mapscr, word version, int scrind)
16719 {
16720
2/2
✓ Branch 0 taken 247176 times.
✓ Branch 1 taken 17000 times.
264176 if(version < 23)
16721 {
16722 247176 auto ret = readmapscreen_old(f,Header,temp_mapscr,version);
16723
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 247176 times.
247176 if(ret) return ret;
16724 247176 }
16725 else
16726 {
16727
1/2
✓ Branch 0 taken 17000 times.
✗ Branch 1 not taken.
17000 if(!p_getc(&(temp_mapscr->valid),f))
16728 return qe_invalid;
16729
2/2
✓ Branch 0 taken 10813 times.
✓ Branch 1 taken 6187 times.
17000 if(!(temp_mapscr->valid & mVALID))
16730 {
16731 10813 int map = scrind/MAPSCRS;
16732 10813 int scr = scrind%MAPSCRS;
16733
4/6
✓ Branch 0 taken 7002 times.
✓ Branch 1 taken 3811 times.
✓ Branch 2 taken 7002 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 7002 times.
✗ Branch 5 not taken.
10813 if(version > 25 && scrind > -1 && (map*6+5) < map_autolayers.size())
16734 {
16735 //Empty screen, apply autolayers
16736
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7002 times.
7002 for(int q = 0; q < 6; ++q)
16737 {
16738 auto layermap = map_autolayers[map*6+q];
16739 temp_mapscr->layermap[q] = layermap;
16740 if(layermap)
16741 temp_mapscr->layerscreen[q] = scr;
16742 }
16743 7002 }
16744 10813 return 0;
16745 }
16746 uint32_t scr_has_flags;
16747
1/2
✓ Branch 0 taken 6187 times.
✗ Branch 1 not taken.
6187 if(!p_igetl(&scr_has_flags,f))
16748 return qe_invalid;
16749
16750
2/2
✓ Branch 0 taken 5241 times.
✓ Branch 1 taken 946 times.
6187 if(scr_has_flags & SCRHAS_ROOMDATA)
16751 {
16752
1/2
✓ Branch 0 taken 946 times.
✗ Branch 1 not taken.
946 if(!p_getc(&(temp_mapscr->guy),f))
16753 return qe_invalid;
16754
2/2
✓ Branch 0 taken 886 times.
✓ Branch 1 taken 60 times.
946 if(version > 26)
16755 {
16756
1/2
✓ Branch 0 taken 886 times.
✗ Branch 1 not taken.
886 if(!p_igetl(&(temp_mapscr->guytile),f))
16757 return qe_invalid;
16758
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 886 times.
886 if(!p_getc(&(temp_mapscr->guycs),f))
16759 return qe_invalid;
16760
1/2
✓ Branch 0 taken 886 times.
✗ Branch 1 not taken.
886 if(!p_igetw(&(temp_mapscr->roomflags),f))
16761 return qe_invalid;
16762 886 }
16763 else
16764 {
16765 60 temp_mapscr->guytile = -1; //signal to use default guy values
16766
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 60 times.
60 SETFLAG(temp_mapscr->roomflags,RFL_ALWAYS_GUY,temp_mapscr->guy==gFAIRY);
16767
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 60 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
60 SETFLAG(temp_mapscr->roomflags,RFL_GUYFIRES,temp_mapscr->guy!=gFAIRY || !get_qr(qr_NOFAIRYGUYFIRES));
16768 }
16769
1/2
✓ Branch 0 taken 946 times.
✗ Branch 1 not taken.
946 if(!p_igetw(&(temp_mapscr->str),f))
16770 return qe_invalid;
16771
1/2
✓ Branch 0 taken 946 times.
✗ Branch 1 not taken.
946 if(!p_getc(&(temp_mapscr->room),f))
16772 return qe_invalid;
16773
1/2
✓ Branch 0 taken 946 times.
✗ Branch 1 not taken.
946 if(!p_igetw(&(temp_mapscr->catchall),f))
16774 return qe_invalid;
16775 946 }
16776
2/2
✓ Branch 0 taken 6060 times.
✓ Branch 1 taken 127 times.
6187 if(scr_has_flags & SCRHAS_ITEM)
16777 {
16778
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 127 times.
127 if(!p_getc(&(temp_mapscr->item),f))
16779 return qe_invalid;
16780
1/2
✓ Branch 0 taken 127 times.
✗ Branch 1 not taken.
127 if(!p_getc(&(temp_mapscr->hasitem),f))
16781 return qe_invalid;
16782
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 127 times.
127 if(!p_getc(&(temp_mapscr->itemx),f))
16783 return qe_invalid;
16784
1/2
✓ Branch 0 taken 127 times.
✗ Branch 1 not taken.
127 if(!p_getc(&(temp_mapscr->itemy),f))
16785 return qe_invalid;
16786 127 }
16787
2/2
✓ Branch 0 taken 5828 times.
✓ Branch 1 taken 359 times.
6187 if(scr_has_flags & (SCRHAS_SWARP|SCRHAS_TWARP))
16788 {
16789
1/2
✓ Branch 0 taken 359 times.
✗ Branch 1 not taken.
359 if(!p_igetw(&temp_mapscr->warpreturnc,f))
16790 return qe_invalid;
16791 359 }
16792
2/2
✓ Branch 0 taken 5941 times.
✓ Branch 1 taken 246 times.
6187 if(scr_has_flags & SCRHAS_TWARP)
16793 {
16794
2/2
✓ Branch 0 taken 984 times.
✓ Branch 1 taken 246 times.
1230 for(int32_t i=0; i<4; i++)
16795 {
16796
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 984 times.
984 if(!p_getc(&(temp_mapscr->tilewarptype[i]),f))
16797 return qe_invalid;
16798 984 }
16799
2/2
✓ Branch 0 taken 984 times.
✓ Branch 1 taken 246 times.
1230 for(int32_t i=0; i<4; i++)
16800 {
16801
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 984 times.
984 if(!p_igetw(&(temp_mapscr->tilewarpdmap[i]),f))
16802 return qe_invalid;
16803 984 }
16804
2/2
✓ Branch 0 taken 984 times.
✓ Branch 1 taken 246 times.
1230 for(int32_t i=0; i<4; i++)
16805 {
16806
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 984 times.
984 if(!p_getc(&(temp_mapscr->tilewarpscr[i]),f))
16807 return qe_invalid;
16808 984 }
16809
1/2
✓ Branch 0 taken 246 times.
✗ Branch 1 not taken.
246 if(!p_getc(&(temp_mapscr->tilewarpoverlayflags),f))
16810 return qe_invalid;
16811 246 }
16812
2/2
✓ Branch 0 taken 6048 times.
✓ Branch 1 taken 139 times.
6187 if(scr_has_flags & SCRHAS_SWARP)
16813 {
16814
2/2
✓ Branch 0 taken 556 times.
✓ Branch 1 taken 139 times.
695 for(int32_t i=0; i<4; i++)
16815 {
16816
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 556 times.
556 if(!p_getc(&(temp_mapscr->sidewarptype[i]),f))
16817 return qe_invalid;
16818 556 }
16819
2/2
✓ Branch 0 taken 556 times.
✓ Branch 1 taken 139 times.
695 for(int32_t i=0; i<4; i++)
16820 {
16821
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 556 times.
556 if(!p_igetw(&(temp_mapscr->sidewarpdmap[i]),f))
16822 return qe_invalid;
16823 556 }
16824
2/2
✓ Branch 0 taken 556 times.
✓ Branch 1 taken 139 times.
695 for(int32_t i=0; i<4; i++)
16825 {
16826
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 556 times.
556 if(!p_getc(&(temp_mapscr->sidewarpscr[i]),f))
16827 return qe_invalid;
16828 556 }
16829
1/2
✓ Branch 0 taken 139 times.
✗ Branch 1 not taken.
139 if(!p_getc(&(temp_mapscr->sidewarpoverlayflags),f))
16830 return qe_invalid;
16831
1/2
✓ Branch 0 taken 139 times.
✗ Branch 1 not taken.
139 if(!p_getc(&(temp_mapscr->sidewarpindex),f))
16832 return qe_invalid;
16833 139 }
16834
2/2
✓ Branch 0 taken 5698 times.
✓ Branch 1 taken 489 times.
6187 if(scr_has_flags & SCRHAS_WARPRET)
16835 {
16836
2/2
✓ Branch 0 taken 1956 times.
✓ Branch 1 taken 489 times.
2445 for(int32_t i=0; i<4; i++)
16837 {
16838
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1956 times.
1956 if(!p_getc(&(temp_mapscr->warpreturnx[i]),f))
16839 return qe_invalid;
16840 1956 }
16841
2/2
✓ Branch 0 taken 1956 times.
✓ Branch 1 taken 489 times.
2445 for(int32_t i=0; i<4; i++)
16842 {
16843
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1956 times.
1956 if(!p_getc(&(temp_mapscr->warpreturny[i]),f))
16844 return qe_invalid;
16845 1956 }
16846
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 489 times.
489 if(!p_getc(&(temp_mapscr->warparrivalx),f))
16847 return qe_invalid;
16848
1/2
✓ Branch 0 taken 489 times.
✗ Branch 1 not taken.
489 if(!p_getc(&(temp_mapscr->warparrivaly),f))
16849 return qe_invalid;
16850 489 }
16851
2/2
✓ Branch 0 taken 5055 times.
✓ Branch 1 taken 1132 times.
6187 if(scr_has_flags & SCRHAS_LAYERS)
16852 {
16853
2/2
✓ Branch 0 taken 6792 times.
✓ Branch 1 taken 1132 times.
7924 for(int32_t k=0; k<6; k++)
16854 {
16855
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6792 times.
6792 if(!p_getc(&(temp_mapscr->layermap[k]),f))
16856 return qe_invalid;
16857 6792 }
16858
2/2
✓ Branch 0 taken 6792 times.
✓ Branch 1 taken 1132 times.
7924 for(int32_t k=0; k<6; k++)
16859 {
16860
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6792 times.
6792 if(!p_getc(&(temp_mapscr->layerscreen[k]),f))
16861 return qe_invalid;
16862 6792 }
16863
2/2
✓ Branch 0 taken 6792 times.
✓ Branch 1 taken 1132 times.
7924 for(int32_t k=0; k<6; k++)
16864 {
16865
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6792 times.
6792 if(!p_getc(&(temp_mapscr->layeropacity[k]),f))
16866 return qe_invalid;
16867 6792 }
16868
1/2
✓ Branch 0 taken 1132 times.
✗ Branch 1 not taken.
1132 if(!p_getc(&(temp_mapscr->hidelayers),f))
16869 return qe_invalid;
16870
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1132 times.
1132 if(!p_getc(&(temp_mapscr->hidescriptlayers),f))
16871 return qe_invalid;
16872 1132 }
16873
1/2
✓ Branch 0 taken 6187 times.
✗ Branch 1 not taken.
6187 if(scr_has_flags & SCRHAS_MAZE)
16874 {
16875 for(int32_t k=0; k<4; k++)
16876 {
16877 if(!p_getc(&(temp_mapscr->path[k]),f))
16878 return qe_invalid;
16879 }
16880 if(!p_getc(&(temp_mapscr->exitdir),f))
16881 return qe_invalid;
16882 }
16883
2/2
✓ Branch 0 taken 213 times.
✓ Branch 1 taken 5974 times.
6187 if(scr_has_flags & SCRHAS_D_S_U)
16884 {
16885
1/2
✓ Branch 0 taken 213 times.
✗ Branch 1 not taken.
213 if(!p_igetw(&(temp_mapscr->door_combo_set),f))
16886 return qe_invalid;
16887
2/2
✓ Branch 0 taken 852 times.
✓ Branch 1 taken 213 times.
1065 for(int32_t k=0; k<4; k++)
16888 {
16889
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 852 times.
852 if(!p_getc(&(temp_mapscr->door[k]),f))
16890 return qe_invalid;
16891
3/4
✓ Branch 0 taken 532 times.
✓ Branch 1 taken 320 times.
✓ Branch 2 taken 532 times.
✗ Branch 3 not taken.
852 if(version < 29 && temp_mapscr->door[k] == dNONE)
16892 temp_mapscr->door[k] = dWALL;
16893 852 }
16894
16895
1/2
✓ Branch 0 taken 213 times.
✗ Branch 1 not taken.
213 if(!p_getc(&(temp_mapscr->stairx),f))
16896 return qe_invalid;
16897
16898
1/2
✓ Branch 0 taken 213 times.
✗ Branch 1 not taken.
213 if(!p_getc(&(temp_mapscr->stairy),f))
16899 return qe_invalid;
16900
1/2
✓ Branch 0 taken 213 times.
✗ Branch 1 not taken.
213 if(!p_igetw(&(temp_mapscr->undercombo),f))
16901 return qe_invalid;
16902
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 213 times.
213 if(!p_getc(&(temp_mapscr->undercset),f))
16903 return qe_invalid;
16904 213 }
16905
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 5966 times.
5974 else if(version < 29)
16906 {
16907
2/2
✓ Branch 0 taken 23864 times.
✓ Branch 1 taken 5966 times.
29830 for(int k = 0; k < 4; ++k)
16908 23864 temp_mapscr->door[k] = dWALL;
16909 5966 }
16910
2/2
✓ Branch 0 taken 5745 times.
✓ Branch 1 taken 442 times.
6187 if(scr_has_flags & SCRHAS_FLAGS)
16911 {
16912
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 442 times.
442 if(!p_getc(&(temp_mapscr->flags),f))
16913 return qe_invalid;
16914
1/2
✓ Branch 0 taken 442 times.
✗ Branch 1 not taken.
442 if(!p_getc(&(temp_mapscr->flags2),f))
16915 return qe_invalid;
16916
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 442 times.
442 if(!p_getc(&(temp_mapscr->flags3),f))
16917 return qe_invalid;
16918
1/2
✓ Branch 0 taken 442 times.
✗ Branch 1 not taken.
442 if(!p_getc(&(temp_mapscr->flags4),f))
16919 return qe_invalid;
16920
1/2
✓ Branch 0 taken 442 times.
✗ Branch 1 not taken.
442 if(!p_getc(&(temp_mapscr->flags5),f))
16921 return qe_invalid;
16922
1/2
✓ Branch 0 taken 442 times.
✗ Branch 1 not taken.
442 if(!p_getc(&(temp_mapscr->flags6),f))
16923 return qe_invalid;
16924
1/2
✓ Branch 0 taken 442 times.
✗ Branch 1 not taken.
442 if(!p_getc(&(temp_mapscr->flags7),f))
16925 return qe_invalid;
16926
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 442 times.
442 if(!p_getc(&(temp_mapscr->flags8),f))
16927 return qe_invalid;
16928
1/2
✓ Branch 0 taken 442 times.
✗ Branch 1 not taken.
442 if(!p_getc(&(temp_mapscr->flags9),f))
16929 return qe_invalid;
16930
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 442 times.
442 if(!p_getc(&(temp_mapscr->flags10),f))
16931 return qe_invalid;
16932
1/2
✓ Branch 0 taken 442 times.
✗ Branch 1 not taken.
442 if(!p_getc(&(temp_mapscr->enemyflags),f))
16933 return qe_invalid;
16934 442 }
16935
2/2
✓ Branch 0 taken 5804 times.
✓ Branch 1 taken 383 times.
6187 if(scr_has_flags & SCRHAS_ENEMY)
16936 {
16937
2/2
✓ Branch 0 taken 3830 times.
✓ Branch 1 taken 383 times.
4213 for(int32_t k=0; k<10; k++)
16938 {
16939
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3830 times.
3830 if(!p_igetw(&(temp_mapscr->enemy[k]),f))
16940 return qe_invalid;
16941
1/2
✓ Branch 0 taken 3830 times.
✗ Branch 1 not taken.
3830 if (unsigned(temp_mapscr->enemy[k]) > MAXGUYS)
16942 temp_mapscr->enemy[k] = 0;
16943 3830 }
16944
1/2
✓ Branch 0 taken 383 times.
✗ Branch 1 not taken.
383 if(!p_getc(&(temp_mapscr->pattern),f))
16945 return qe_invalid;
16946 383 }
16947
2/2
✓ Branch 0 taken 6154 times.
✓ Branch 1 taken 33 times.
6187 if(scr_has_flags & SCRHAS_CARRY)
16948 {
16949
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 33 times.
33 if(!p_igetw(&(temp_mapscr->noreset),f))
16950 return qe_invalid;
16951
1/2
✓ Branch 0 taken 33 times.
✗ Branch 1 not taken.
33 if(!p_igetw(&(temp_mapscr->nocarry),f))
16952 return qe_invalid;
16953
1/2
✓ Branch 0 taken 33 times.
✗ Branch 1 not taken.
33 if(!p_getc(&(temp_mapscr->nextmap),f))
16954 return qe_invalid;
16955
1/2
✓ Branch 0 taken 33 times.
✗ Branch 1 not taken.
33 if(!p_getc(&(temp_mapscr->nextscr),f))
16956 return qe_invalid;
16957 33 }
16958
2/2
✓ Branch 0 taken 6114 times.
✓ Branch 1 taken 73 times.
6187 if(scr_has_flags & SCRHAS_SCRIPT)
16959 {
16960
1/2
✓ Branch 0 taken 73 times.
✗ Branch 1 not taken.
73 if(!p_igetw(&(temp_mapscr->script),f))
16961 return qe_invalid;
16962
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 73 times.
73 if(!p_getc(&(temp_mapscr->preloadscript),f))
16963 return qe_invalid;
16964
2/2
✓ Branch 0 taken 584 times.
✓ Branch 1 taken 73 times.
657 for ( int32_t q = 0; q < 8; q++ )
16965 {
16966
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 584 times.
584 if(!p_igetl(&(temp_mapscr->screeninitd[q]),f))
16967 return qe_invalid;
16968 584 }
16969 73 }
16970
1/2
✓ Branch 0 taken 6187 times.
✗ Branch 1 not taken.
6187 if(scr_has_flags & SCRHAS_UNUSED)
16971 {
16972 for ( int32_t q = 0; q < 10; q++ )
16973 {
16974 if(!p_igetl(&(temp_mapscr->npcstrings[q]),f))
16975 return qe_invalid;
16976 }
16977 for ( int32_t q = 0; q < 10; q++ )
16978 {
16979 if(!p_igetw(&(temp_mapscr->new_items[q]),f))
16980 return qe_invalid;
16981 }
16982 for ( int32_t q = 0; q < 10; q++ )
16983 {
16984 if(!p_igetw(&(temp_mapscr->new_item_x[q]),f))
16985 return qe_invalid;
16986 }
16987 for ( int32_t q = 0; q < 10; q++ )
16988 {
16989 if(!p_igetw(&(temp_mapscr->new_item_y[q]),f))
16990 return qe_invalid;
16991 }
16992 }
16993
2/2
✓ Branch 0 taken 5758 times.
✓ Branch 1 taken 429 times.
6187 if(scr_has_flags & SCRHAS_SECRETS)
16994 {
16995
2/2
✓ Branch 0 taken 54912 times.
✓ Branch 1 taken 429 times.
55341 for(int32_t k=0; k<128; k++)
16996 {
16997
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 54912 times.
54912 if(!p_igetw(&(temp_mapscr->secretcombo[k]),f))
16998 return qe_invalid;
16999 54912 }
17000
2/2
✓ Branch 0 taken 54912 times.
✓ Branch 1 taken 429 times.
55341 for(int32_t k=0; k<128; k++)
17001 {
17002
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 54912 times.
54912 if(!p_getc(&(temp_mapscr->secretcset[k]),f))
17003 return qe_invalid;
17004 54912 }
17005
2/2
✓ Branch 0 taken 54912 times.
✓ Branch 1 taken 429 times.
55341 for(int32_t k=0; k<128; k++)
17006 {
17007
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 54912 times.
54912 if(!p_getc(&(temp_mapscr->secretflag[k]),f))
17008 return qe_invalid;
17009 54912 }
17010 429 }
17011
2/2
✓ Branch 0 taken 2945 times.
✓ Branch 1 taken 3242 times.
6187 if(scr_has_flags & SCRHAS_COMBOFLAG)
17012 {
17013
2/2
✓ Branch 0 taken 570592 times.
✓ Branch 1 taken 3242 times.
573834 for(int32_t k=0; k<176; ++k)
17014 {
17015
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 570592 times.
570592 if(!p_igetw(&(temp_mapscr->data[k]),f))
17016 return qe_invalid;
17017 570592 }
17018
2/2
✓ Branch 0 taken 570592 times.
✓ Branch 1 taken 3242 times.
573834 for(int32_t k=0; k<176; ++k)
17019 {
17020
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 570592 times.
570592 if(!p_getc(&(temp_mapscr->sflag[k]),f))
17021 return qe_invalid;
17022 570592 }
17023
2/2
✓ Branch 0 taken 570592 times.
✓ Branch 1 taken 3242 times.
573834 for(int32_t k=0; k<176; ++k)
17024 {
17025
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 570592 times.
570592 if(!p_getc(&(temp_mapscr->cset[k]),f))
17026 return qe_invalid;
17027 570592 }
17028 3242 }
17029
1/2
✓ Branch 0 taken 6187 times.
✗ Branch 1 not taken.
6187 if(scr_has_flags & SCRHAS_MISC)
17030 {
17031
1/2
✓ Branch 0 taken 6187 times.
✗ Branch 1 not taken.
6187 if(!p_igetw(&(temp_mapscr->color),f))
17032 return qe_invalid;
17033
1/2
✓ Branch 0 taken 6187 times.
✗ Branch 1 not taken.
6187 if(!p_getc(&(temp_mapscr->csensitive),f))
17034 return qe_invalid;
17035
1/2
✓ Branch 0 taken 6187 times.
✗ Branch 1 not taken.
6187 if(!p_getc(&(temp_mapscr->oceansfx),f))
17036 return qe_invalid;
17037
1/2
✓ Branch 0 taken 6187 times.
✗ Branch 1 not taken.
6187 if(!p_getc(&(temp_mapscr->bosssfx),f))
17038 return qe_invalid;
17039
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6187 times.
6187 if(!p_getc(&(temp_mapscr->secretsfx),f))
17040 return qe_invalid;
17041
1/2
✓ Branch 0 taken 6187 times.
✗ Branch 1 not taken.
6187 if(!p_getc(&(temp_mapscr->holdupsfx),f))
17042 return qe_invalid;
17043
1/2
✓ Branch 0 taken 6187 times.
✗ Branch 1 not taken.
6187 if(!p_igetw(&(temp_mapscr->timedwarptics),f))
17044 return qe_invalid;
17045
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6187 times.
6187 if(!p_igetw(&(temp_mapscr->screen_midi),f))
17046 return qe_invalid;
17047
1/2
✓ Branch 0 taken 6187 times.
✗ Branch 1 not taken.
6187 if(!p_getc(&(temp_mapscr->lens_layer),f))
17048 return qe_invalid;
17049
2/2
✓ Branch 0 taken 5301 times.
✓ Branch 1 taken 886 times.
6187 if(version > 27)
17050 {
17051
1/2
✓ Branch 0 taken 886 times.
✗ Branch 1 not taken.
886 if(!p_getc(&(temp_mapscr->lens_show),f))
17052 return qe_invalid;
17053
1/2
✓ Branch 0 taken 886 times.
✗ Branch 1 not taken.
886 if(!p_getc(&(temp_mapscr->lens_hide),f))
17054 return qe_invalid;
17055 886 }
17056 6187 }
17057 else
17058 {
17059 temp_mapscr->screen_midi = -1;
17060 temp_mapscr->csensitive = 1;
17061 }
17062 //FFC
17063 6187 bool old_ff = version < 25;
17064 6187 dword bits = 0;
17065 6187 word numffc = 32;
17066
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6187 times.
6187 if(old_ff)
17067 {
17068 if(!p_igetl(&bits,f))
17069 return qe_invalid;
17070 }
17071 else
17072 {
17073
1/2
✓ Branch 0 taken 6187 times.
✗ Branch 1 not taken.
6187 if(!p_igetw(&numffc,f))
17074 return qe_invalid;
17075 }
17076 byte tempbyte;
17077 word tempw;
17078
4/6
✓ Branch 0 taken 34 times.
✓ Branch 1 taken 6153 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 34 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 34 times.
6187 static ffcdata nil_ffc;
17079 6187 temp_mapscr->ffcCountMarkDirty();
17080
2/2
✓ Branch 0 taken 6187 times.
✓ Branch 1 taken 8724 times.
14911 for(word m = 0; m < numffc; ++m)
17081 {
17082
1/2
✓ Branch 0 taken 8724 times.
✗ Branch 1 not taken.
8724 ffcdata& tempffc = (m < MAXFFCS)
17083 8724 ? temp_mapscr->ffcs[m]
17084 : nil_ffc; //sanity
17085 8724 tempffc.clear();
17086
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 8724 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
8724 if(old_ff && !(bits & (1<<m))) continue;
17087
17088
1/2
✓ Branch 0 taken 8724 times.
✗ Branch 1 not taken.
8724 if(!p_igetw(&tempw,f))
17089 return qe_invalid;
17090
3/4
✓ Branch 0 taken 8724 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1898 times.
✓ Branch 3 taken 6826 times.
8724 if(!old_ff && !tempw) //empty ffc, nothing more to load
17091 6826 continue;
17092 1898 tempffc.data = tempw;
17093
17094
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1898 times.
1898 if(!p_getc(&(tempffc.cset),f))
17095 return qe_invalid;
17096
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1898 times.
1898 if(!p_igetw(&(tempffc.delay),f))
17097 return qe_invalid;
17098
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1898 times.
1898 if(!p_igetzf(&(tempffc.x),f))
17099 return qe_invalid;
17100
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1898 times.
1898 if(!p_igetzf(&(tempffc.y),f))
17101 return qe_invalid;
17102
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1898 times.
1898 if(!p_igetzf(&(tempffc.vx),f))
17103 return qe_invalid;
17104
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1898 times.
1898 if(!p_igetzf(&(tempffc.vy),f))
17105 return qe_invalid;
17106
1/2
✓ Branch 0 taken 1898 times.
✗ Branch 1 not taken.
1898 if(!p_igetzf(&(tempffc.ax),f))
17107 return qe_invalid;
17108
1/2
✓ Branch 0 taken 1898 times.
✗ Branch 1 not taken.
1898 if(!p_igetzf(&(tempffc.ay),f))
17109 return qe_invalid;
17110
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1898 times.
1898 if(!p_getc(&(tempffc.link),f))
17111 return qe_invalid;
17112
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1898 times.
1898 if(version < 24)
17113 {
17114 if(!p_getc(&tempbyte,f))
17115 return qe_invalid;
17116 tempffc.hit_width = (tempbyte&0x3F)+1;
17117 tempffc.txsz = (tempbyte>>6)+1;
17118 if(!p_getc(&tempbyte,f))
17119 return qe_invalid;
17120 tempffc.hit_height = (tempbyte&0x3F)+1;
17121 tempffc.tysz = (tempbyte>>6)+1;
17122 }
17123 else
17124 {
17125
1/2
✓ Branch 0 taken 1898 times.
✗ Branch 1 not taken.
1898 if(!p_igetl(&(tempffc.hit_width),f))
17126 return qe_invalid;
17127
1/2
✓ Branch 0 taken 1898 times.
✗ Branch 1 not taken.
1898 if(!p_igetl(&(tempffc.hit_height),f))
17128 return qe_invalid;
17129
1/2
✓ Branch 0 taken 1898 times.
✗ Branch 1 not taken.
1898 if(!p_getc(&(tempffc.txsz),f))
17130 return qe_invalid;
17131
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1898 times.
1898 if(!p_getc(&(tempffc.tysz),f))
17132 return qe_invalid;
17133 }
17134
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1898 times.
1898 if(!p_igetl(&(tempffc.flags),f))
17135 return qe_invalid;
17136 1898 tempffc.updateSolid();
17137
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1898 times.
1898 if(!p_igetw(&(tempffc.script),f))
17138 return qe_invalid;
17139
2/2
✓ Branch 0 taken 15184 times.
✓ Branch 1 taken 1898 times.
17082 for(auto q = 0; q < 8; ++q)
17140 {
17141
1/2
✓ Branch 0 taken 15184 times.
✗ Branch 1 not taken.
15184 if(!p_igetl(&(tempffc.initd[q]),f))
17142 return qe_invalid;
17143 15184 }
17144
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1898 times.
1898 if(!p_getc(&(tempbyte),f))
17145 return qe_invalid;
17146 1898 tempffc.inita[0]=tempbyte*10000;
17147
17148
1/2
✓ Branch 0 taken 1898 times.
✗ Branch 1 not taken.
1898 if(!p_getc(&(tempbyte),f))
17149 return qe_invalid;
17150 1898 tempffc.inita[1]=tempbyte*10000;
17151
17152
1/2
✓ Branch 0 taken 1898 times.
✗ Branch 1 not taken.
1898 if(loading_tileset_flags & TILESET_CLEARSCRIPTS)
17153 {
17154 tempffc.script = 0;
17155 for(int q = 0; q < 8; ++q)
17156 tempffc.initd[q] = 0;
17157 }
17158 1898 }
17159
2/2
✓ Branch 0 taken 783212 times.
✓ Branch 1 taken 6187 times.
789399 for(word m = numffc; m < MAXFFCS; ++m)
17160 {
17161 783212 temp_mapscr->ffcs[m].clear();
17162 783212 }
17163 //END FFC
17164 }
17165 253363 return 0;
17166 264176 }
17167
17168
17169 131 int32_t readmaps(PACKFILE *f, zquestheader *Header)
17170 {
17171
2/2
✓ Branch 0 taken 127 times.
✓ Branch 1 taken 4 times.
131 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_maps);
17172 131 int32_t scr=0;
17173
17174 131 word version=0;
17175 dword dummy;
17176 int32_t screens_to_read;
17177
17178 131 mapscr temp_mapscr;
17179 word temp_map_count;
17180 dword section_size;
17181
17182
3/6
✓ Branch 0 taken 127 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 127 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
131 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<137)))
17183 {
17184 4 screens_to_read=MAPSCRS192b136;
17185 4 }
17186 else
17187 {
17188 127 screens_to_read=MAPSCRS;
17189 }
17190
17191
2/2
✓ Branch 0 taken 127 times.
✓ Branch 1 taken 4 times.
131 if(Header->zelda_version > 0x192)
17192 {
17193 //section version info
17194
2/4
✓ Branch 0 taken 127 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 127 times.
✗ Branch 3 not taken.
127 if(!p_igetw(&version,f))
17195 {
17196 return qe_invalid;
17197 }
17198
17199 127 FFCore.quest_format[vMaps] = version;
17200
17201 //al_trace("Maps version %d\n", version);
17202
2/4
✓ Branch 0 taken 127 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 127 times.
✗ Branch 3 not taken.
127 if(!p_igetw(&dummy,f))
17203 {
17204 return qe_invalid;
17205 }
17206
17207 //section size
17208
2/4
✓ Branch 0 taken 127 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 127 times.
✗ Branch 3 not taken.
127 if(!p_igetl(&section_size,f))
17209 {
17210 return qe_invalid;
17211 }
17212
17213 //finally... section data
17214
2/4
✓ Branch 0 taken 127 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 127 times.
✗ Branch 3 not taken.
127 if(!p_igetw(&temp_map_count,f))
17215 {
17216 return 5;
17217 }
17218 127 }
17219 else
17220 {
17221 4 temp_map_count=map_count;
17222 }
17223
17224
2/4
✓ Branch 0 taken 131 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 131 times.
✗ Branch 3 not taken.
131 if (!(temp_map_count >= 0 && temp_map_count <= MAXMAPS))
17225 {
17226 return qe_invalid;
17227 }
17228
17229
1/2
✓ Branch 0 taken 131 times.
✗ Branch 1 not taken.
131 if (!should_skip)
17230 {
17231 131 const int32_t _mapsSize = MAPSCRS*temp_map_count;
17232
1/2
✓ Branch 0 taken 131 times.
✗ Branch 1 not taken.
131 TheMaps.resize(_mapsSize);
17233 131 map_autolayers.clear();
17234
1/2
✓ Branch 0 taken 131 times.
✗ Branch 1 not taken.
131 map_autolayers.resize(temp_map_count*6);
17235
2/2
✓ Branch 0 taken 265336 times.
✓ Branch 1 taken 131 times.
265467 for(int32_t i(0); i<_mapsSize; i++)
17236
1/2
✓ Branch 0 taken 265336 times.
✗ Branch 1 not taken.
265336 TheMaps[i].zero_memory();
17237 131 }
17238
17239
1/2
✓ Branch 0 taken 131 times.
✗ Branch 1 not taken.
131 temp_mapscr.zero_memory();
17240
17241
4/4
✓ Branch 0 taken 131 times.
✓ Branch 1 taken 1951 times.
✓ Branch 2 taken 131 times.
✓ Branch 3 taken 1951 times.
2082 for(int32_t i=0; i<temp_map_count && i<MAXMAPS; i++)
17242 {
17243 1951 byte valid=1;
17244
2/2
✓ Branch 0 taken 132 times.
✓ Branch 1 taken 1819 times.
1951 if(version > 22)
17245 {
17246
2/4
✓ Branch 0 taken 132 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 132 times.
✗ Branch 3 not taken.
132 if(!p_getc(&valid,f))
17247 return qe_invalid;
17248 132 }
17249
4/4
✓ Branch 0 taken 1944 times.
✓ Branch 1 taken 7 times.
✓ Branch 2 taken 1886 times.
✓ Branch 3 taken 58 times.
1951 if(valid && version > 25)
17250 {
17251
2/2
✓ Branch 0 taken 348 times.
✓ Branch 1 taken 58 times.
406 for(int q = 0; q < 6; ++q)
17252 {
17253
2/4
✓ Branch 0 taken 348 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 348 times.
✗ Branch 3 not taken.
348 if(!p_igetw(&map_autolayers[i*6+q],f))
17254 return qe_invalid;
17255 348 }
17256 58 }
17257
2/2
✓ Branch 0 taken 265128 times.
✓ Branch 1 taken 1951 times.
267079 for(int32_t j=0; j<screens_to_read; j++)
17258 {
17259 265128 scr=i*MAPSCRS+j;
17260
1/2
✓ Branch 0 taken 265128 times.
✗ Branch 1 not taken.
265128 clear_screen(&temp_mapscr);
17261
2/2
✓ Branch 0 taken 264176 times.
✓ Branch 1 taken 952 times.
265128 if(valid)
17262
1/2
✓ Branch 0 taken 264176 times.
✗ Branch 1 not taken.
264176 readmapscreen(f, Header, &temp_mapscr, version, scr);
17263
17264
1/2
✓ Branch 0 taken 265128 times.
✗ Branch 1 not taken.
265128 if (!should_skip)
17265
1/2
✓ Branch 0 taken 265128 times.
✗ Branch 1 not taken.
265128 TheMaps[scr] = temp_mapscr;
17266 265128 }
17267
17268
1/2
✓ Branch 0 taken 1951 times.
✗ Branch 1 not taken.
1951 if (should_skip)
17269 continue;
17270
17271
3/6
✓ Branch 0 taken 1899 times.
✓ Branch 1 taken 52 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1899 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1951 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<137)))
17272 {
17273 52 int32_t index = (i*MAPSCRS+132);
17274
17275
1/2
✓ Branch 0 taken 52 times.
✗ Branch 1 not taken.
52 TheMaps[index]=TheMaps[index-1];
17276
17277 52 MEMCPY_ARR(TheMaps[i*MAPSCRS+132].data, TheMaps[i*MAPSCRS+131].data);
17278 52 MEMCPY_ARR(TheMaps[i*MAPSCRS+132].sflag, TheMaps[i*MAPSCRS+131].sflag);
17279 52 MEMCPY_ARR(TheMaps[i*MAPSCRS+132].cset, TheMaps[i*MAPSCRS+131].cset);
17280
17281
2/2
✓ Branch 0 taken 156 times.
✓ Branch 1 taken 52 times.
208 for(int32_t j=133; j<MAPSCRS; j++)
17282 {
17283 156 scr=i*MAPSCRS+j;
17284
17285
1/2
✓ Branch 0 taken 156 times.
✗ Branch 1 not taken.
156 TheMaps[scr].zero_memory();
17286 156 TheMaps[scr].valid = mVERSION;
17287 156 TheMaps[scr].screen_midi = -1;
17288 156 TheMaps[scr].csensitive = 1;
17289 156 }
17290 52 }
17291
17292
3/6
✓ Branch 0 taken 1899 times.
✓ Branch 1 taken 52 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1899 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1951 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<154)))
17293 {
17294
2/2
✓ Branch 0 taken 7072 times.
✓ Branch 1 taken 52 times.
7124 for(int32_t j=0; j<MAPSCRS; j++)
17295 {
17296 7072 scr=i*MAPSCRS+j;
17297 7072 TheMaps[scr].door_combo_set=MakeDoors(i, j);
17298
17299
2/2
✓ Branch 0 taken 905216 times.
✓ Branch 1 taken 7072 times.
912288 for(int32_t k=0; k<128; k++)
17300 {
17301
1/2
✓ Branch 0 taken 905216 times.
✗ Branch 1 not taken.
905216 TheMaps[scr].secretcset[k]=tcmbcset2(i, TheMaps[scr].secretcombo[k]);
17302
1/2
✓ Branch 0 taken 905216 times.
✗ Branch 1 not taken.
905216 TheMaps[scr].secretflag[k]=tcmbflag2(i, TheMaps[scr].secretcombo[k]);
17303
1/2
✓ Branch 0 taken 905216 times.
✗ Branch 1 not taken.
905216 TheMaps[scr].secretcombo[k]=tcmbdat2(i, j, TheMaps[scr].secretcombo[k]);
17304 905216 }
17305 7072 }
17306 52 }
17307 1951 }
17308 131 map_count = temp_map_count;
17309
1/2
✓ Branch 0 taken 131 times.
✗ Branch 1 not taken.
131 clear_screen(&temp_mapscr);
17310 131 return 0;
17311 131 }
17312
17313
17314 1104685 void update_combo(newcombo& cmb, word section_version)
17315 {
17316
2/2
✓ Branch 0 taken 163968 times.
✓ Branch 1 taken 940717 times.
1104685 if(section_version < 40)
17317 {
17318
3/3
✓ Branch 0 taken 1389 times.
✓ Branch 1 taken 14209 times.
✓ Branch 2 taken 925119 times.
940717 switch(cmb.type)
17319 {
17320 case cWATER: case cSHALLOWWATER:
17321 14209 cmb.attribytes[6] = iwRipples;
17322 14209 break;
17323 case cTALLGRASS: case cTALLGRASSNEXT: case cTALLGRASSTOUCHY:
17324 1389 cmb.attribytes[6] = iwTallGrass;
17325 1389 break;
17326 }
17327 940717 }
17328 1104685 }
17329 95 int32_t readcombos_old(word section_version, PACKFILE *f, zquestheader *, word version, word build, word start_combo, word max_combos)
17330 {
17331
2/2
✓ Branch 0 taken 91 times.
✓ Branch 1 taken 4 times.
95 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_combos);
17332
17333
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 95 times.
95 if (!should_skip)
17334 {
17335 95 reset_combo_animations();
17336 95 reset_combo_animations2();
17337 95 init_combo_classes();
17338 95 }
17339
17340 // combos
17341 95 word combos_used=0;
17342 int32_t dummy;
17343 byte padding;
17344 95 newcombo temp_combo;
17345 //word section_cversion=0;
17346
17347
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 95 times.
95 if (!should_skip)
17348
2/2
✓ Branch 0 taken 6201600 times.
✓ Branch 1 taken 95 times.
6201695 for(int32_t q = start_combo; q < start_combo+max_combos; ++q)
17349
1/2
✓ Branch 0 taken 6201600 times.
✗ Branch 1 not taken.
6201695 combobuf[q].clear();
17350
17351 // if(version > 0x192)
17352 // {
17353 // //section version info
17354 // if(!p_igetw(&section_version,f))
17355 // {
17356 // return qe_invalid;
17357 // }
17358
17359 // FFCore.quest_format[vCombos] = section_version;
17360
17361 // //al_trace("Combos version %d\n", section_version);
17362 // if(!p_igetw(&section_cversion,f))
17363 // {
17364 // return qe_invalid;
17365 // }
17366
17367 // //section size
17368 // if(!p_igetl(&dummy,f))
17369 // {
17370 // return qe_invalid;
17371 // }
17372 // }
17373
17374
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 95 times.
95 if(version < 0x174)
17375 {
17376 combos_used=1024;
17377 }
17378
2/2
✓ Branch 0 taken 91 times.
✓ Branch 1 taken 4 times.
95 else if(version < 0x191)
17379 {
17380 4 combos_used=2048;
17381 4 }
17382 else
17383 {
17384
2/4
✓ Branch 0 taken 91 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 91 times.
✗ Branch 3 not taken.
91 if(!p_igetw(&combos_used,f))
17385 {
17386 return qe_invalid;
17387 }
17388 }
17389
17390 //finally... section data
17391
2/2
✓ Branch 0 taken 873209 times.
✓ Branch 1 taken 95 times.
873304 for(int32_t i=0; i<combos_used; i++)
17392 {
17393
1/2
✓ Branch 0 taken 873209 times.
✗ Branch 1 not taken.
873209 temp_combo.clear();
17394
17395
2/2
✓ Branch 0 taken 68884 times.
✓ Branch 1 taken 804325 times.
873209 if ( section_version >= 11 )
17396 {
17397
2/4
✓ Branch 0 taken 68884 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 68884 times.
✗ Branch 3 not taken.
68884 if(!p_igetl(&temp_combo.tile,f))
17398 {
17399 return qe_invalid;
17400 }
17401 68884 }
17402 else
17403 {
17404
2/4
✓ Branch 0 taken 804325 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 804325 times.
✗ Branch 3 not taken.
804325 if(!p_igetw(&temp_combo.tile,f))
17405 {
17406 return qe_invalid;
17407 }
17408 }
17409 873209 temp_combo.o_tile = temp_combo.tile;
17410
2/4
✓ Branch 0 taken 873209 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 873209 times.
✗ Branch 3 not taken.
873209 if(!p_getc(&temp_combo.flip,f))
17411 {
17412 return qe_invalid;
17413 }
17414
17415
2/4
✓ Branch 0 taken 873209 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 873209 times.
✗ Branch 3 not taken.
873209 if(!p_getc(&temp_combo.walk,f))
17416 {
17417 return qe_invalid;
17418 }
17419
17420
2/4
✓ Branch 0 taken 873209 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 873209 times.
✗ Branch 3 not taken.
873209 if(!p_getc(&temp_combo.type,f))
17421 {
17422 return qe_invalid;
17423 }
17424
17425
2/4
✓ Branch 0 taken 873209 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 873209 times.
✗ Branch 3 not taken.
873209 if(!p_getc(&temp_combo.csets,f))
17426 {
17427 return qe_invalid;
17428 }
17429
17430
2/2
✓ Branch 0 taken 8192 times.
✓ Branch 1 taken 865017 times.
873209 if(version < 0x193)
17431 {
17432
2/4
✓ Branch 0 taken 8192 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8192 times.
✗ Branch 3 not taken.
8192 if(!p_getc(&padding,f))
17433 return qe_invalid;
17434
17435
2/4
✓ Branch 0 taken 8192 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8192 times.
✗ Branch 3 not taken.
8192 if(!p_getc(&padding,f))
17436 return qe_invalid;
17437
17438
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8192 times.
8192 if(version < 0x192)
17439 {
17440
1/2
✓ Branch 0 taken 8192 times.
✗ Branch 1 not taken.
8192 if(version == 0x191)
17441 {
17442 for(int32_t tmpcounter=0; tmpcounter<16; tmpcounter++)
17443 {
17444 if(!p_getc(&padding,f))
17445 return qe_invalid;
17446 }
17447 }
17448 8192 }
17449 8192 }
17450
2/2
✓ Branch 0 taken 865017 times.
✓ Branch 1 taken 8192 times.
873209 if(version >= 0x192)
17451 {
17452
2/4
✓ Branch 0 taken 865017 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 865017 times.
✗ Branch 3 not taken.
865017 if(!p_getc(&temp_combo.frames,f))
17453 return qe_invalid;
17454
17455
2/4
✓ Branch 0 taken 865017 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 865017 times.
✗ Branch 3 not taken.
865017 if(!p_getc(&temp_combo.speed,f))
17456 return qe_invalid;
17457
17458
2/4
✓ Branch 0 taken 865017 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 865017 times.
✗ Branch 3 not taken.
865017 if(!p_igetw(&temp_combo.nextcombo,f))
17459 return qe_invalid;
17460
17461
2/4
✓ Branch 0 taken 865017 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 865017 times.
✗ Branch 3 not taken.
865017 if(!p_getc(&temp_combo.nextcset,f))
17462 return qe_invalid;
17463
17464 //Base flag
17465
2/2
✓ Branch 0 taken 399183 times.
✓ Branch 1 taken 465834 times.
865017 if(section_version>=3)
17466
2/4
✓ Branch 0 taken 399183 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 399183 times.
✗ Branch 3 not taken.
399183 if(!p_getc(&temp_combo.flag,f))
17467 return qe_invalid;
17468
17469
2/2
✓ Branch 0 taken 399183 times.
✓ Branch 1 taken 465834 times.
865017 if(section_version>=4)
17470 {
17471
2/4
✓ Branch 0 taken 399183 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 399183 times.
✗ Branch 3 not taken.
399183 if(!p_getc(&temp_combo.skipanim,f))
17472 return qe_invalid;
17473
17474
2/4
✓ Branch 0 taken 399183 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 399183 times.
✗ Branch 3 not taken.
399183 if(!p_igetw(&temp_combo.nexttimer,f))
17475 return qe_invalid;
17476 399183 }
17477
17478
2/2
✓ Branch 0 taken 399183 times.
✓ Branch 1 taken 465834 times.
865017 if(section_version>=5)
17479
2/4
✓ Branch 0 taken 399183 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 399183 times.
✗ Branch 3 not taken.
399183 if(!p_getc(&temp_combo.skipanimy,f))
17480 return qe_invalid;
17481
17482
2/2
✓ Branch 0 taken 399183 times.
✓ Branch 1 taken 465834 times.
865017 if(section_version>=6)
17483 {
17484
2/4
✓ Branch 0 taken 399183 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 399183 times.
✗ Branch 3 not taken.
399183 if(!p_getc(&temp_combo.animflags,f))
17485 return qe_invalid;
17486
17487
1/2
✓ Branch 0 taken 399183 times.
✗ Branch 1 not taken.
399183 if(section_version == 6)
17488 temp_combo.animflags = temp_combo.animflags ? AF_FRESH : 0;
17489 399183 }
17490
17491
2/2
✓ Branch 0 taken 796133 times.
✓ Branch 1 taken 68884 times.
865017 if(section_version>=8) //combo Attributes[4] and userflags.
17492 {
17493
2/2
✓ Branch 0 taken 68884 times.
✓ Branch 1 taken 275536 times.
344420 for ( int32_t q = 0; q < NUM_COMBO_ATTRIBUTES; q++ )
17494
2/4
✓ Branch 0 taken 275536 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 275536 times.
✗ Branch 3 not taken.
275536 if(!p_igetl(&temp_combo.attributes[q],f))
17495 return qe_invalid;
17496
2/4
✓ Branch 0 taken 68884 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 68884 times.
✗ Branch 3 not taken.
68884 if(!p_igetl(&temp_combo.usrflags,f))
17497 return qe_invalid;
17498
1/2
✓ Branch 0 taken 68884 times.
✗ Branch 1 not taken.
68884 if(section_version >= 20)
17499
2/4
✓ Branch 0 taken 68884 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 68884 times.
✗ Branch 3 not taken.
68884 if(!p_igetw(&temp_combo.genflags,f))
17500 return qe_invalid;
17501 68884 }
17502
2/2
✓ Branch 0 taken 68884 times.
✓ Branch 1 taken 796133 times.
865017 if(section_version>=10) //combo trigger flags
17503 {
17504
2/2
✓ Branch 0 taken 206652 times.
✓ Branch 1 taken 68884 times.
275536 for ( int32_t q = 0; q < 3; q++ )
17505
2/4
✓ Branch 0 taken 206652 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 206652 times.
✗ Branch 3 not taken.
206652 if(!p_igetl(&temp_combo.triggerflags[q],f))
17506 return qe_invalid;
17507 68884 }
17508
1/2
✓ Branch 0 taken 796133 times.
✗ Branch 1 not taken.
796133 else if(section_version==9) //combo trigger flags, V9 only had two indices of triggerflags[]
17509 {
17510 for ( int32_t q = 0; q < 2; q++ )
17511 if(!p_igetl(&temp_combo.triggerflags[q],f))
17512 return qe_invalid;
17513 }
17514
2/2
✓ Branch 0 taken 68884 times.
✓ Branch 1 taken 796133 times.
865017 if(section_version >= 9)
17515
2/4
✓ Branch 0 taken 68884 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 68884 times.
✗ Branch 3 not taken.
68884 if(!p_igetl(&temp_combo.triggerlevel,f))
17516 return qe_invalid;
17517
2/2
✓ Branch 0 taken 68884 times.
✓ Branch 1 taken 796133 times.
865017 if(section_version >= 22)
17518
2/4
✓ Branch 0 taken 68884 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 68884 times.
✗ Branch 3 not taken.
68884 if(!p_getc(&temp_combo.triggerbtn,f))
17519 return qe_invalid;
17520
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 865017 times.
865017 if(section_version >= 24)
17521 {
17522 if(!p_getc(&temp_combo.triggeritem,f))
17523 return qe_invalid;
17524 if(!p_getc(&temp_combo.trigtimer,f))
17525 return qe_invalid;
17526 }
17527
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 865017 times.
865017 if(section_version >= 25)
17528 if(!p_getc(&temp_combo.trigsfx,f))
17529 return qe_invalid;
17530
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 865017 times.
865017 if(section_version >= 27)
17531 if(!p_igetl(&temp_combo.trigchange,f))
17532 return qe_invalid;
17533
17534
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 865017 times.
865017 if(section_version >= 29)
17535 {
17536 if(!p_igetw(&temp_combo.trigprox,f))
17537 return qe_invalid;
17538 if(!p_getc(&temp_combo.trigctr,f))
17539 return qe_invalid;
17540 if(!p_igetl(&temp_combo.trigctramnt,f))
17541 return qe_invalid;
17542 }
17543
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 865017 times.
865017 if(section_version >= 30)
17544 if(!p_getc(&temp_combo.triglbeam,f))
17545 return qe_invalid;
17546
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 865017 times.
865017 if(section_version >= 31)
17547 {
17548 if(!p_getc(&temp_combo.trigcschange,f))
17549 return qe_invalid;
17550 if(!p_igetw(&temp_combo.spawnitem,f))
17551 return qe_invalid;
17552 if(!p_igetw(&temp_combo.spawnenemy,f))
17553 return qe_invalid;
17554 if(!p_getc(&temp_combo.exstate,f))
17555 return qe_invalid;
17556 if(!p_igetl(&temp_combo.spawnip,f))
17557 return qe_invalid;
17558 if(!p_getc(&temp_combo.trigcopycat,f))
17559 return qe_invalid;
17560 }
17561
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 865017 times.
865017 if(section_version >= 32)
17562 if(!p_getc(&temp_combo.trigcooldown,f))
17563 return qe_invalid;
17564
17565
2/2
✓ Branch 0 taken 796133 times.
✓ Branch 1 taken 68884 times.
865017 if(section_version>=12) //combo label
17566 {
17567 char label[12];
17568 68884 label[11] = '\0';
17569
2/2
✓ Branch 0 taken 68884 times.
✓ Branch 1 taken 757724 times.
826608 for ( int32_t q = 0; q < 11; q++ )
17570
2/4
✓ Branch 0 taken 757724 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 757724 times.
✗ Branch 3 not taken.
757724 if(!p_getc(&label[q],f))
17571 return qe_invalid;
17572
1/2
✓ Branch 0 taken 68884 times.
✗ Branch 1 not taken.
68884 temp_combo.label = label;
17573 68884 }
17574
2/2
✓ Branch 0 taken 796133 times.
✓ Branch 1 taken 68884 times.
865017 if(section_version>=13) //attribytes[4]
17575
2/2
✓ Branch 0 taken 275536 times.
✓ Branch 1 taken 68884 times.
344420 for ( int32_t q = 0; q < 4; q++ )
17576
2/4
✓ Branch 0 taken 275536 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 275536 times.
✗ Branch 3 not taken.
275536 if(!p_getc(&temp_combo.attribytes[q],f))
17577 68884 return qe_invalid;
17578 /* HIGHLY UNORTHODOX UPDATING THING, by Deedee
17579 * This fixes a poor implementation of a ->next flag bug thing.
17580 * Zoria didn't bump up the versions as liberally as he should have, but thankfully
17581 * there was a version bump a few weeks before a change that broke stuff.
17582 */
17583
3/4
✓ Branch 0 taken 68884 times.
✓ Branch 1 taken 796133 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 68884 times.
865017 if (section_version >= 13 && section_version < 21)
17584 {
17585 set_qr(qr_BUGGY_BUGGY_SLASH_TRIGGERS,1);
17586 }
17587 //combo scripts
17588
2/2
✓ Branch 0 taken 68884 times.
✓ Branch 1 taken 796133 times.
865017 if(section_version>=14)
17589 {
17590
2/4
✓ Branch 0 taken 68884 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 68884 times.
✗ Branch 3 not taken.
68884 if(!p_igetw(&temp_combo.script,f))
17591 return qe_invalid;
17592
2/2
✓ Branch 0 taken 137768 times.
✓ Branch 1 taken 68884 times.
206652 for ( int32_t q = 0; q < 2; q++ )
17593
2/4
✓ Branch 0 taken 137768 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 137768 times.
✗ Branch 3 not taken.
137768 if(!p_igetl(&temp_combo.initd[q],f))
17594 return qe_invalid;
17595 68884 }
17596 //al_trace("Read combo script data\n");
17597
2/2
✓ Branch 0 taken 68884 times.
✓ Branch 1 taken 796133 times.
865017 if(section_version>=15)
17598 {
17599
2/4
✓ Branch 0 taken 68884 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 68884 times.
✗ Branch 3 not taken.
68884 if(!p_igetl(&temp_combo.o_tile,f)) return qe_invalid;
17600
2/2
✓ Branch 0 taken 37028 times.
✓ Branch 1 taken 31856 times.
68884 if(!temp_combo.o_tile) temp_combo.o_tile = temp_combo.tile;
17601
2/4
✓ Branch 0 taken 68884 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 68884 times.
✗ Branch 3 not taken.
68884 if(!p_getc(&temp_combo.cur_frame,f)) return qe_invalid;
17602
2/4
✓ Branch 0 taken 68884 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 68884 times.
✗ Branch 3 not taken.
68884 if(!p_getc(&temp_combo.aclk,f)) return qe_invalid;
17603 68884 }
17604
2/2
✓ Branch 0 taken 796133 times.
✓ Branch 1 taken 68884 times.
865017 if(section_version>=17) //attribytes[4]
17605 {
17606
2/2
✓ Branch 0 taken 275536 times.
✓ Branch 1 taken 68884 times.
344420 for ( int32_t q = 4; q < 8; q++ ) //bump up attribytes...
17607
2/4
✓ Branch 0 taken 275536 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 275536 times.
✗ Branch 3 not taken.
275536 if(!p_getc(&temp_combo.attribytes[q],f))
17608 return qe_invalid;
17609
2/2
✓ Branch 0 taken 551072 times.
✓ Branch 1 taken 68884 times.
619956 for ( int32_t q = 0; q < 8; q++ ) //...and add attrishorts
17610
2/4
✓ Branch 0 taken 551072 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 551072 times.
✗ Branch 3 not taken.
551072 if(!p_igetw(&temp_combo.attrishorts[q],f))
17611 return qe_invalid;
17612 68884 }
17613
17614
1/2
✓ Branch 0 taken 865017 times.
✗ Branch 1 not taken.
865017 if(version < 0x193)
17615 for(int32_t q=0; q<11; q++)
17616 if(!p_getc(&dummy,f))
17617 return qe_invalid;
17618 865017 }
17619
17620 //Goriya tiles were flipped around in 2.11 build 7. Compensate for the flip here. -DD
17621
3/6
✓ Branch 0 taken 399183 times.
✓ Branch 1 taken 474026 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 399183 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
873209 if((version < 0x211)||((version == 0x211)&&(build<7)))
17622 {
17623
2/2
✓ Branch 0 taken 465834 times.
✓ Branch 1 taken 8192 times.
474026 if(!get_qr(qr_NEWENEMYTILES))
17624 {
17625
1/5
✓ Branch 0 taken 8192 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
8192 switch(temp_combo.tile)
17626 {
17627 case 130:
17628 temp_combo.tile = 132;
17629 break;
17630
17631 case 131:
17632 temp_combo.tile = 133;
17633 break;
17634
17635 case 132:
17636 temp_combo.tile = 130;
17637 break;
17638
17639 case 133:
17640 temp_combo.tile = 131;
17641 break;
17642 }
17643 8192 }
17644 474026 }
17645
17646
2/2
✓ Branch 0 taken 68884 times.
✓ Branch 1 taken 804325 times.
873209 if(section_version < 15)
17647 804325 temp_combo.o_tile = temp_combo.tile;
17648
17649
2/2
✓ Branch 0 taken 68884 times.
✓ Branch 1 taken 804325 times.
873209 if(section_version<18) //upper bits for .walk
17650 804325 temp_combo.walk |= 0xF0;
17651
17652
2/2
✓ Branch 0 taken 68884 times.
✓ Branch 1 taken 804325 times.
873209 if(section_version < 19)
17653
2/2
✓ Branch 0 taken 3217300 times.
✓ Branch 1 taken 804325 times.
4021625 for(int32_t q = 0; q < 4; ++q)
17654 4021625 temp_combo.attributes[q] *= 10000L;
17655
17656
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 873209 times.
873209 if(section_version < 23)
17657 {
17658
2/2
✓ Branch 0 taken 384 times.
✓ Branch 1 taken 872825 times.
873209 switch(temp_combo.type) //combotriggerCMBTYPEFX now required for combotype-specific effects
17659 {
17660 case cSCRIPT1: case cSCRIPT2: case cSCRIPT3: case cSCRIPT4: case cSCRIPT5:
17661 case cSCRIPT6: case cSCRIPT7: case cSCRIPT8: case cSCRIPT9: case cSCRIPT10:
17662 case cTRIGGERGENERIC: case cCSWITCH:
17663 384 temp_combo.triggerflags[0] |= combotriggerCMBTYPEFX;
17664 384 }
17665 873209 }
17666
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 873209 times.
873209 if(section_version < 25)
17667 {
17668
2/2
✓ Branch 0 taken 3061 times.
✓ Branch 1 taken 870148 times.
873209 switch(temp_combo.type)
17669 {
17670 case cLOCKBLOCK: case cBOSSLOCKBLOCK:
17671
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3061 times.
3061 if(!(temp_combo.usrflags & cflag3))
17672 3061 temp_combo.attribytes[3] = WAV_DOOR;
17673 3061 temp_combo.usrflags &= ~cflag3;
17674 3061 break;
17675 }
17676 873209 }
17677
17678
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 873209 times.
873209 if(section_version < 26)
17679
2/2
✓ Branch 0 taken 872622 times.
✓ Branch 1 taken 587 times.
873796 if(temp_combo.type == cARMOS)
17680
1/2
✓ Branch 0 taken 587 times.
✗ Branch 1 not taken.
587 if(temp_combo.usrflags & cflag1)
17681 temp_combo.usrflags |= cflag3;
17682
17683
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 873209 times.
873209 if(section_version < 27)
17684 {
17685
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 873209 times.
873209 if(temp_combo.triggerflags[0] & 0x00040000) //'next'
17686 temp_combo.trigchange = 1;
17687
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 873209 times.
873209 else if(temp_combo.triggerflags[0] & 0x00080000) //'prev'
17688 temp_combo.trigchange = -1;
17689 873209 else temp_combo.trigchange = 0;
17690 873209 temp_combo.triggerflags[0] &= ~(0x00040000|0x00080000);
17691 873209 }
17692
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 873209 times.
873209 if(section_version < 28)
17693 {
17694
2/2
✓ Branch 0 taken 1689 times.
✓ Branch 1 taken 871520 times.
873209 switch(temp_combo.type)
17695 {
17696 case cLOCKBLOCK: case cLOCKEDCHEST:
17697
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1689 times.
1689 if(temp_combo.usrflags & cflag7)
17698 temp_combo.usrflags |= cflag8;
17699 1689 else temp_combo.usrflags &= ~cflag8;
17700 1689 temp_combo.usrflags &= ~cflag7;
17701 1689 break;
17702 }
17703
2/2
✓ Branch 0 taken 69 times.
✓ Branch 1 taken 873140 times.
873209 switch(temp_combo.type)
17704 {
17705 case cCHEST: case cLOCKEDCHEST: case cBOSSCHEST:
17706 69 temp_combo.attrishorts[2] = -1;
17707 69 temp_combo.usrflags |= cflag7;
17708 69 break;
17709 }
17710 873209 }
17711
2/2
✓ Branch 0 taken 68884 times.
✓ Branch 1 taken 804325 times.
873209 if(section_version < 20)
17712 {
17713 804325 temp_combo.genflags = 0;
17714
2/2
✓ Branch 0 taken 19291 times.
✓ Branch 1 taken 785034 times.
804325 switch(temp_combo.type)
17715 {
17716 case cPUSH_WAIT: case cPUSH_HEAVY:
17717 case cPUSH_HW: case cL_STATUE:
17718 case cR_STATUE: case cPUSH_HEAVY2:
17719 case cPUSH_HW2: case cPOUND:
17720 case cC_STATUE: case cMIRROR:
17721 case cMIRRORSLASH: case cMIRRORBACKSLASH:
17722 case cMAGICPRISM: case cMAGICPRISM4:
17723 case cMAGICSPONGE: case cEYEBALL_A:
17724 case cEYEBALL_B: case cEYEBALL_4:
17725 case cBUSH: case cFLOWERS:
17726 case cLOCKBLOCK: case cLOCKBLOCK2:
17727 case cBOSSLOCKBLOCK: case cBOSSLOCKBLOCK2:
17728 case cCHEST: case cCHEST2:
17729 case cLOCKEDCHEST: case cLOCKEDCHEST2:
17730 case cBOSSCHEST: case cBOSSCHEST2:
17731 case cBUSHNEXT: case cBUSHTOUCHY:
17732 case cFLOWERSTOUCHY: case cBUSHNEXTTOUCHY:
17733 case cSIGNPOST: case cCSWITCHBLOCK:
17734 case cTORCH: case cTRIGGERGENERIC:
17735
1/2
✓ Branch 0 taken 19291 times.
✗ Branch 1 not taken.
19291 if(temp_combo.usrflags & cflag16)
17736 {
17737 temp_combo.genflags |= cflag1;
17738 temp_combo.usrflags &= ~cflag16;
17739 }
17740 19291 break;
17741 }
17742 804325 }
17743
17744 873209 update_combo(temp_combo, section_version);
17745
17746
2/4
✓ Branch 0 taken 873209 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 873209 times.
✗ Branch 3 not taken.
873209 if(i>=start_combo && !should_skip)
17747 {
17748
1/2
✓ Branch 0 taken 873209 times.
✗ Branch 1 not taken.
873209 if(loading_tileset_flags & TILESET_CLEARSCRIPTS)
17749 {
17750 temp_combo.script = 0;
17751 for(int q = 0; q < 8; ++q)
17752 temp_combo.initd[q] = 0;
17753 }
17754
1/2
✓ Branch 0 taken 873209 times.
✗ Branch 1 not taken.
873209 combobuf[i] = temp_combo;
17755 873209 }
17756 873209 }
17757
17758
1/2
✓ Branch 0 taken 95 times.
✗ Branch 1 not taken.
95 if (should_skip)
17759 return 0;
17760
17761
3/6
✓ Branch 0 taken 91 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 91 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
95 if((version < 0x192)|| ((version == 0x192)&&(build<185)))
17762 {
17763
2/2
✓ Branch 0 taken 261120 times.
✓ Branch 1 taken 4 times.
261124 for(int32_t tmpcounter=0; tmpcounter<MAXCOMBOS; tmpcounter++)
17764 {
17765
1/2
✓ Branch 0 taken 261120 times.
✗ Branch 1 not taken.
261120 if(combobuf[tmpcounter].type==cHOOKSHOTONLY)
17766 {
17767 combobuf[tmpcounter].type=cLADDERHOOKSHOT;
17768 }
17769 261120 }
17770 4 }
17771
17772 //June 3 2012; ladder only is broken in 2.10 and allows the hookshot also. -Gleeok
17773
4/6
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 83 times.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 12 times.
95 if(version == 0x210 && !is_editor())
17774 {
17775
2/2
✓ Branch 0 taken 783360 times.
✓ Branch 1 taken 12 times.
783372 for(int32_t tmpcounter=0; tmpcounter<MAXCOMBOS; tmpcounter++)
17776
2/2
✓ Branch 0 taken 783351 times.
✓ Branch 1 taken 9 times.
783369 if(combobuf[tmpcounter].type == cLADDERONLY)
17777 9 combobuf[tmpcounter].type = cLADDERHOOKSHOT;
17778 12 }
17779
17780
2/2
✓ Branch 0 taken 79 times.
✓ Branch 1 taken 16 times.
95 if(section_version<7)
17781 {
17782
2/2
✓ Branch 0 taken 1044480 times.
✓ Branch 1 taken 16 times.
1044496 for(int32_t tmpcounter=0; tmpcounter<MAXCOMBOS; tmpcounter++)
17783 {
17784
6/9
✓ Branch 0 taken 1043840 times.
✓ Branch 1 taken 250 times.
✓ Branch 2 taken 174 times.
✓ Branch 3 taken 126 times.
✓ Branch 4 taken 45 times.
✓ Branch 5 taken 45 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
1044480 switch(combobuf[tmpcounter].type)
17785 {
17786 case cSLASH:
17787 250 combobuf[tmpcounter].type=cSLASHTOUCHY;
17788 250 break;
17789
17790 case cSLASHITEM:
17791 174 combobuf[tmpcounter].type=cSLASHITEMTOUCHY;
17792 174 break;
17793
17794 case cBUSH:
17795 126 combobuf[tmpcounter].type=cBUSHTOUCHY;
17796 126 break;
17797
17798 case cFLOWERS:
17799 45 combobuf[tmpcounter].type=cFLOWERSTOUCHY;
17800 45 break;
17801
17802 case cTALLGRASS:
17803 45 combobuf[tmpcounter].type=cTALLGRASSTOUCHY;
17804 45 break;
17805
17806 case cSLASHNEXT:
17807 combobuf[tmpcounter].type=cSLASHNEXTTOUCHY;
17808 break;
17809
17810 case cSLASHNEXTITEM:
17811 combobuf[tmpcounter].type=cSLASHNEXTITEMTOUCHY;
17812 break;
17813
17814 case cBUSHNEXT:
17815 combobuf[tmpcounter].type=cBUSHNEXTTOUCHY;
17816 break;
17817 }
17818 1044480 }
17819 16 }
17820
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 93 times.
95 if (section_version < 16)
17821 {
17822
2/2
✓ Branch 0 taken 6071040 times.
✓ Branch 1 taken 93 times.
6071133 for(int32_t tmpcounter=0; tmpcounter<MAXCOMBOS; tmpcounter++)
17823 {
17824
2/2
✓ Branch 0 taken 6062986 times.
✓ Branch 1 taken 8054 times.
6071040 if (combobuf[tmpcounter].type == cWATER)
17825 {
17826 8054 combobuf[tmpcounter].attributes[0] = 40000L;
17827 8054 }
17828 6071040 }
17829 93 }
17830
2/2
✓ Branch 0 taken 94 times.
✓ Branch 1 taken 1 times.
95 if(!get_qr(qr_ALLOW_EDITING_COMBO_0))
17831 {
17832 1 combobuf[0].walk = 0xF0;
17833 1 combobuf[0].type = 0;
17834 1 combobuf[0].flag = 0;
17835 1 }
17836
17837 //Now for the new combo alias reset
17838
2/2
✓ Branch 0 taken 79 times.
✓ Branch 1 taken 16 times.
95 if(section_version<2)
17839 {
17840
2/2
✓ Branch 0 taken 131072 times.
✓ Branch 1 taken 16 times.
131088 for(int32_t j=0; j<MAXCOMBOALIASES; j++)
17841 {
17842 131072 combo_aliases[j].width = 0;
17843 131072 combo_aliases[j].height = 0;
17844 131072 combo_aliases[j].layermask = 0;
17845
17846
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 131072 times.
131072 if(combo_aliases[j].combos != NULL)
17847 {
17848
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 131072 times.
131072 delete[] combo_aliases[j].combos;
17849 131072 }
17850
17851
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 131072 times.
131072 if(combo_aliases[j].csets != NULL)
17852 {
17853
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 131072 times.
131072 delete[] combo_aliases[j].csets;
17854 131072 }
17855
17856
1/2
✓ Branch 0 taken 131072 times.
✗ Branch 1 not taken.
131072 combo_aliases[j].combos = new word[1];
17857
1/2
✓ Branch 0 taken 131072 times.
✗ Branch 1 not taken.
131072 combo_aliases[j].csets = new byte[1];
17858 131072 combo_aliases[j].combos[0] = 0;
17859 131072 combo_aliases[j].csets[0] = 0;
17860 131072 }
17861 16 }
17862
17863
17864
1/2
✓ Branch 0 taken 95 times.
✗ Branch 1 not taken.
95 setup_combo_animations();
17865
1/2
✓ Branch 0 taken 95 times.
✗ Branch 1 not taken.
95 setup_combo_animations2();
17866 95 return 0;
17867 95 }
17868 231476 int32_t readcombo_loop(PACKFILE* f, word s_version, newcombo& temp_combo)
17869 {
17870 byte combo_has_flags;
17871
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 231476 times.
231476 if(!p_getc(&combo_has_flags,f))
17872 return qe_invalid;
17873
17874 231476 temp_combo.clear();
17875
2/2
✓ Branch 0 taken 154407 times.
✓ Branch 1 taken 77069 times.
231476 if(combo_has_flags)
17876 {
17877
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 77066 times.
77069 if(combo_has_flags&CHAS_BASIC)
17878 {
17879
1/2
✓ Branch 0 taken 77066 times.
✗ Branch 1 not taken.
77066 if(!p_igetl(&temp_combo.tile,f))
17880 {
17881 return qe_invalid;
17882 }
17883 77066 temp_combo.o_tile = temp_combo.tile;
17884
17885
1/2
✓ Branch 0 taken 77066 times.
✗ Branch 1 not taken.
77066 if(!p_getc(&temp_combo.flip,f))
17886 {
17887 return qe_invalid;
17888 }
17889
17890
1/2
✓ Branch 0 taken 77066 times.
✗ Branch 1 not taken.
77066 if(!p_getc(&temp_combo.walk,f))
17891 {
17892 return qe_invalid;
17893 }
17894
17895
1/2
✓ Branch 0 taken 77066 times.
✗ Branch 1 not taken.
77066 if(!p_getc(&temp_combo.type,f))
17896 {
17897 return qe_invalid;
17898 }
17899
17900
1/2
✓ Branch 0 taken 77066 times.
✗ Branch 1 not taken.
77066 if(!p_getc(&temp_combo.flag,f))
17901 {
17902 return qe_invalid;
17903 }
17904
17905
1/2
✓ Branch 0 taken 77066 times.
✗ Branch 1 not taken.
77066 if(!p_getc(&temp_combo.csets,f))
17906 {
17907 return qe_invalid;
17908 }
17909 77066 }
17910
2/2
✓ Branch 0 taken 77046 times.
✓ Branch 1 taken 23 times.
77069 if(combo_has_flags&CHAS_SCRIPT)
17911 {
17912
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 15 times.
23 if (s_version>=41)
17913 {
17914 8 p_getcstr(&temp_combo.label, f);
17915 8 }
17916 else
17917 {
17918 char label[12];
17919 15 label[11] = '\0';
17920
2/2
✓ Branch 0 taken 165 times.
✓ Branch 1 taken 15 times.
180 for ( int32_t q = 0; q < 11; q++ )
17921 {
17922
1/2
✓ Branch 0 taken 165 times.
✗ Branch 1 not taken.
165 if(!p_getc(&label[q],f))
17923 {
17924 return qe_invalid;
17925 }
17926 165 }
17927 15 temp_combo.label = label;
17928 }
17929
17930
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 if(!p_igetw(&temp_combo.script,f)) return qe_invalid;
17931 23 auto initd_count = s_version >= 43 ? 8 : 2;
17932
2/2
✓ Branch 0 taken 94 times.
✓ Branch 1 taken 23 times.
117 for ( int32_t q = 0; q < initd_count; q++ )
17933 {
17934
1/2
✓ Branch 0 taken 94 times.
✗ Branch 1 not taken.
94 if(!p_igetl(&temp_combo.initd[q],f))
17935 {
17936 return qe_invalid;
17937 }
17938 94 }
17939 23 }
17940
2/2
✓ Branch 0 taken 56324 times.
✓ Branch 1 taken 20745 times.
77069 if(combo_has_flags&CHAS_ANIM)
17941 {
17942
1/2
✓ Branch 0 taken 20745 times.
✗ Branch 1 not taken.
20745 if(!p_getc(&temp_combo.frames,f))
17943 {
17944 return qe_invalid;
17945 }
17946
17947
1/2
✓ Branch 0 taken 20745 times.
✗ Branch 1 not taken.
20745 if(!p_getc(&temp_combo.speed,f))
17948 {
17949 return qe_invalid;
17950 }
17951
17952
1/2
✓ Branch 0 taken 20745 times.
✗ Branch 1 not taken.
20745 if(!p_igetw(&temp_combo.nextcombo,f))
17953 {
17954 return qe_invalid;
17955 }
17956
17957
1/2
✓ Branch 0 taken 20745 times.
✗ Branch 1 not taken.
20745 if(!p_getc(&temp_combo.nextcset,f))
17958 {
17959 return qe_invalid;
17960 }
17961
17962
1/2
✓ Branch 0 taken 20745 times.
✗ Branch 1 not taken.
20745 if(!p_getc(&temp_combo.skipanim,f))
17963 {
17964 return qe_invalid;
17965 }
17966
17967
1/2
✓ Branch 0 taken 20745 times.
✗ Branch 1 not taken.
20745 if(!p_getc(&temp_combo.skipanimy,f))
17968 {
17969 return qe_invalid;
17970 }
17971
17972
1/2
✓ Branch 0 taken 20745 times.
✗ Branch 1 not taken.
20745 if(!p_getc(&temp_combo.animflags,f))
17973 {
17974 return qe_invalid;
17975 }
17976 20745 }
17977
2/2
✓ Branch 0 taken 67569 times.
✓ Branch 1 taken 9500 times.
77069 if(combo_has_flags&CHAS_ATTRIB)
17978 {
17979
2/2
✓ Branch 0 taken 38000 times.
✓ Branch 1 taken 9500 times.
47500 for ( int32_t q = 0; q < 4; q++ )
17980 {
17981
1/2
✓ Branch 0 taken 38000 times.
✗ Branch 1 not taken.
38000 if(!p_igetl(&temp_combo.attributes[q],f))
17982 {
17983 return qe_invalid;
17984 }
17985 38000 }
17986
2/2
✓ Branch 0 taken 76000 times.
✓ Branch 1 taken 9500 times.
85500 for ( int32_t q = 0; q < 8; q++ )
17987 {
17988
1/2
✓ Branch 0 taken 76000 times.
✗ Branch 1 not taken.
76000 if(!p_getc(&temp_combo.attribytes[q],f))
17989 {
17990 return qe_invalid;
17991 }
17992 76000 }
17993
2/2
✓ Branch 0 taken 76000 times.
✓ Branch 1 taken 9500 times.
85500 for ( int32_t q = 0; q < 8; q++ )
17994 {
17995
1/2
✓ Branch 0 taken 76000 times.
✗ Branch 1 not taken.
76000 if(!p_igetw(&temp_combo.attrishorts[q],f))
17996 {
17997 return qe_invalid;
17998 }
17999 76000 }
18000 9500 }
18001
2/2
✓ Branch 0 taken 74721 times.
✓ Branch 1 taken 2348 times.
77069 if(combo_has_flags&CHAS_FLAG)
18002 {
18003
1/2
✓ Branch 0 taken 2348 times.
✗ Branch 1 not taken.
2348 if(!p_igetl(&temp_combo.usrflags,f))
18004 {
18005 return qe_invalid;
18006 }
18007
1/2
✓ Branch 0 taken 2348 times.
✗ Branch 1 not taken.
2348 if(!p_igetw(&temp_combo.genflags,f))
18008 {
18009 return qe_invalid;
18010 }
18011 2348 }
18012
2/2
✓ Branch 0 taken 76258 times.
✓ Branch 1 taken 811 times.
77069 if(combo_has_flags&CHAS_TRIG)
18013 {
18014 811 int numtrigs = s_version < 36 ? 3 : 6;
18015
2/2
✓ Branch 0 taken 4437 times.
✓ Branch 1 taken 811 times.
5248 for ( int32_t q = 0; q < numtrigs; q++ )
18016 {
18017
1/2
✓ Branch 0 taken 4437 times.
✗ Branch 1 not taken.
4437 if(!p_igetl(&temp_combo.triggerflags[q],f))
18018 {
18019 return qe_invalid;
18020 }
18021 4437 }
18022
1/2
✓ Branch 0 taken 811 times.
✗ Branch 1 not taken.
811 if(!p_igetl(&temp_combo.triggerlevel,f))
18023 {
18024 return qe_invalid;
18025 }
18026
1/2
✓ Branch 0 taken 811 times.
✗ Branch 1 not taken.
811 if(!p_getc(&temp_combo.triggerbtn,f))
18027 {
18028 return qe_invalid;
18029 }
18030
1/2
✓ Branch 0 taken 811 times.
✗ Branch 1 not taken.
811 if(!p_getc(&temp_combo.triggeritem,f))
18031 {
18032 return qe_invalid;
18033 }
18034
1/2
✓ Branch 0 taken 811 times.
✗ Branch 1 not taken.
811 if(!p_getc(&temp_combo.trigtimer,f))
18035 {
18036 return qe_invalid;
18037 }
18038
1/2
✓ Branch 0 taken 811 times.
✗ Branch 1 not taken.
811 if(!p_getc(&temp_combo.trigsfx,f))
18039 {
18040 return qe_invalid;
18041 }
18042
1/2
✓ Branch 0 taken 811 times.
✗ Branch 1 not taken.
811 if(!p_igetl(&temp_combo.trigchange,f))
18043 {
18044 return qe_invalid;
18045 }
18046
1/2
✓ Branch 0 taken 811 times.
✗ Branch 1 not taken.
811 if(!p_igetw(&temp_combo.trigprox,f))
18047 {
18048 return qe_invalid;
18049 }
18050
1/2
✓ Branch 0 taken 811 times.
✗ Branch 1 not taken.
811 if(!p_getc(&temp_combo.trigctr,f))
18051 {
18052 return qe_invalid;
18053 }
18054
1/2
✓ Branch 0 taken 811 times.
✗ Branch 1 not taken.
811 if(!p_igetl(&temp_combo.trigctramnt,f))
18055 {
18056 return qe_invalid;
18057 }
18058
1/2
✓ Branch 0 taken 811 times.
✗ Branch 1 not taken.
811 if(!p_getc(&temp_combo.triglbeam,f))
18059 {
18060 return qe_invalid;
18061 }
18062
1/2
✓ Branch 0 taken 811 times.
✗ Branch 1 not taken.
811 if(!p_getc(&temp_combo.trigcschange,f))
18063 {
18064 return qe_invalid;
18065 }
18066
1/2
✓ Branch 0 taken 811 times.
✗ Branch 1 not taken.
811 if(!p_igetw(&temp_combo.spawnitem,f))
18067 {
18068 return qe_invalid;
18069 }
18070
1/2
✓ Branch 0 taken 811 times.
✗ Branch 1 not taken.
811 if(!p_igetw(&temp_combo.spawnenemy,f))
18071 {
18072 return qe_invalid;
18073 }
18074
1/2
✓ Branch 0 taken 811 times.
✗ Branch 1 not taken.
811 if(!p_getc(&temp_combo.exstate,f))
18075 {
18076 return qe_invalid;
18077 }
18078
1/2
✓ Branch 0 taken 811 times.
✗ Branch 1 not taken.
811 if(!p_igetl(&temp_combo.spawnip,f))
18079 {
18080 return qe_invalid;
18081 }
18082
1/2
✓ Branch 0 taken 811 times.
✗ Branch 1 not taken.
811 if(!p_getc(&temp_combo.trigcopycat,f))
18083 {
18084 return qe_invalid;
18085 }
18086
1/2
✓ Branch 0 taken 811 times.
✗ Branch 1 not taken.
811 if(!p_getc(&temp_combo.trigcooldown,f))
18087 {
18088 return qe_invalid;
18089 }
18090
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 811 times.
811 if(s_version >= 35)
18091 {
18092
1/2
✓ Branch 0 taken 811 times.
✗ Branch 1 not taken.
811 if(!p_igetw(&temp_combo.prompt_cid,f))
18093 {
18094 return qe_invalid;
18095 }
18096
1/2
✓ Branch 0 taken 811 times.
✗ Branch 1 not taken.
811 if(!p_getc(&temp_combo.prompt_cs,f))
18097 {
18098 return qe_invalid;
18099 }
18100
1/2
✓ Branch 0 taken 811 times.
✗ Branch 1 not taken.
811 if(!p_igetw(&temp_combo.prompt_x,f))
18101 {
18102 return qe_invalid;
18103 }
18104
1/2
✓ Branch 0 taken 811 times.
✗ Branch 1 not taken.
811 if(!p_igetw(&temp_combo.prompt_y,f))
18105 {
18106 return qe_invalid;
18107 }
18108 811 }
18109
2/2
✓ Branch 0 taken 143 times.
✓ Branch 1 taken 668 times.
811 if(s_version >= 36)
18110 {
18111
1/2
✓ Branch 0 taken 668 times.
✗ Branch 1 not taken.
668 if(!p_getc(&temp_combo.trig_lstate,f))
18112 {
18113 return qe_invalid;
18114 }
18115
1/2
✓ Branch 0 taken 668 times.
✗ Branch 1 not taken.
668 if(!p_getc(&temp_combo.trig_gstate,f))
18116 {
18117 return qe_invalid;
18118 }
18119
1/2
✓ Branch 0 taken 668 times.
✗ Branch 1 not taken.
668 if(!p_igetl(&temp_combo.trig_statetime,f))
18120 {
18121 return qe_invalid;
18122 }
18123 668 }
18124
2/2
✓ Branch 0 taken 143 times.
✓ Branch 1 taken 668 times.
811 if(s_version >= 37)
18125 {
18126
1/2
✓ Branch 0 taken 668 times.
✗ Branch 1 not taken.
668 if(!p_igetw(&temp_combo.trig_genscr,f))
18127 {
18128 return qe_invalid;
18129 }
18130 668 }
18131
2/2
✓ Branch 0 taken 217 times.
✓ Branch 1 taken 594 times.
811 if(s_version >= 38)
18132 {
18133
1/2
✓ Branch 0 taken 594 times.
✗ Branch 1 not taken.
594 if(!p_getc(&temp_combo.trig_group,f))
18134 {
18135 return qe_invalid;
18136 }
18137
1/2
✓ Branch 0 taken 594 times.
✗ Branch 1 not taken.
594 if(!p_igetw(&temp_combo.trig_group_val,f))
18138 {
18139 return qe_invalid;
18140 }
18141 594 }
18142 811 }
18143
2/2
✓ Branch 0 taken 76918 times.
✓ Branch 1 taken 151 times.
77069 if(combo_has_flags&CHAS_LIFT)
18144 {
18145
1/2
✓ Branch 0 taken 151 times.
✗ Branch 1 not taken.
151 if(!p_igetw(&temp_combo.liftcmb,f))
18146 return qe_invalid;
18147
1/2
✓ Branch 0 taken 151 times.
✗ Branch 1 not taken.
151 if(!p_getc(&temp_combo.liftcs,f))
18148 return qe_invalid;
18149
1/2
✓ Branch 0 taken 151 times.
✗ Branch 1 not taken.
151 if(!p_igetw(&temp_combo.liftundercmb,f))
18150 return qe_invalid;
18151
1/2
✓ Branch 0 taken 151 times.
✗ Branch 1 not taken.
151 if(!p_getc(&temp_combo.liftundercs,f))
18152 return qe_invalid;
18153
1/2
✓ Branch 0 taken 151 times.
✗ Branch 1 not taken.
151 if(!p_getc(&temp_combo.liftdmg,f))
18154 return qe_invalid;
18155
1/2
✓ Branch 0 taken 151 times.
✗ Branch 1 not taken.
151 if(!p_getc(&temp_combo.liftlvl,f))
18156 return qe_invalid;
18157
1/2
✓ Branch 0 taken 151 times.
✗ Branch 1 not taken.
151 if(!p_getc(&temp_combo.liftitm,f))
18158 return qe_invalid;
18159
1/2
✓ Branch 0 taken 151 times.
✗ Branch 1 not taken.
151 if(!p_getc(&temp_combo.liftflags,f))
18160 return qe_invalid;
18161
1/2
✓ Branch 0 taken 151 times.
✗ Branch 1 not taken.
151 if(!p_getc(&temp_combo.liftgfx,f))
18162 return qe_invalid;
18163
1/2
✓ Branch 0 taken 151 times.
✗ Branch 1 not taken.
151 if(!p_getc(&temp_combo.liftsprite,f))
18164 return qe_invalid;
18165
1/2
✓ Branch 0 taken 151 times.
✗ Branch 1 not taken.
151 if(!p_getc(&temp_combo.liftsfx,f))
18166 return qe_invalid;
18167
1/2
✓ Branch 0 taken 151 times.
✗ Branch 1 not taken.
151 if(!p_igetw(&temp_combo.liftbreaksprite,f))
18168 return qe_invalid;
18169
1/2
✓ Branch 0 taken 151 times.
✗ Branch 1 not taken.
151 if(!p_getc(&temp_combo.liftbreaksfx,f))
18170 return qe_invalid;
18171
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 151 times.
151 if(s_version >= 34)
18172 {
18173
1/2
✓ Branch 0 taken 151 times.
✗ Branch 1 not taken.
151 if(!p_getc(&temp_combo.lifthei,f))
18174 return qe_invalid;
18175
1/2
✓ Branch 0 taken 151 times.
✗ Branch 1 not taken.
151 if(!p_getc(&temp_combo.lifttime,f))
18176 return qe_invalid;
18177 151 }
18178
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 144 times.
151 if(s_version >= 39)
18179 {
18180
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_getc(&temp_combo.lift_parent_item,f))
18181 return qe_invalid;
18182 144 }
18183 151 }
18184
2/2
✓ Branch 0 taken 76969 times.
✓ Branch 1 taken 100 times.
77069 if(combo_has_flags&CHAS_GENERAL)
18185 {
18186
1/2
✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
100 if(!p_getc(&temp_combo.speed_mult,f))
18187 return qe_invalid;
18188
1/2
✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
100 if(!p_getc(&temp_combo.speed_div,f))
18189 return qe_invalid;
18190
1/2
✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
100 if(!p_igetzf(&temp_combo.speed_add,f))
18191 return qe_invalid;
18192
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 100 times.
100 if(s_version >= 42)
18193 {
18194
1/2
✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
100 if(!p_getc(&temp_combo.sfx_appear,f))
18195 return qe_invalid;
18196
1/2
✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
100 if(!p_getc(&temp_combo.sfx_disappear,f))
18197 return qe_invalid;
18198
1/2
✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
100 if(!p_getc(&temp_combo.sfx_loop,f))
18199 return qe_invalid;
18200
1/2
✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
100 if(!p_getc(&temp_combo.sfx_walking,f))
18201 return qe_invalid;
18202
1/2
✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
100 if(!p_getc(&temp_combo.sfx_standing,f))
18203 return qe_invalid;
18204
1/2
✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
100 if(!p_getc(&temp_combo.spr_appear,f))
18205 return qe_invalid;
18206
1/2
✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
100 if(!p_getc(&temp_combo.spr_disappear,f))
18207 return qe_invalid;
18208
1/2
✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
100 if(!p_getc(&temp_combo.spr_walking,f))
18209 return qe_invalid;
18210
1/2
✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
100 if(!p_getc(&temp_combo.spr_standing,f))
18211 return qe_invalid;
18212 100 }
18213
2/2
✓ Branch 0 taken 84 times.
✓ Branch 1 taken 16 times.
100 if(s_version >= 44)
18214 {
18215
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_getc(&temp_combo.sfx_tap,f))
18216 return qe_invalid;
18217 16 }
18218 100 }
18219 77069 }
18220 231476 update_combo(temp_combo, s_version);
18221 231476 return 0;
18222 231476 }
18223 131 int32_t readcombos(PACKFILE *f, zquestheader *Header, word version, word build, word start_combo, word max_combos)
18224 {
18225
2/2
✓ Branch 0 taken 127 times.
✓ Branch 1 taken 4 times.
131 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_combos);
18226
18227 131 word section_version=0;
18228 131 word section_cversion=0;
18229 131 word combos_used=0;
18230 int32_t dummy;
18231 byte padding;
18232 131 newcombo temp_combo;
18233
18234
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 131 times.
131 if (!should_skip)
18235 {
18236
1/2
✓ Branch 0 taken 131 times.
✗ Branch 1 not taken.
131 reset_combo_animations();
18237
1/2
✓ Branch 0 taken 131 times.
✗ Branch 1 not taken.
131 reset_combo_animations2();
18238
1/2
✓ Branch 0 taken 131 times.
✗ Branch 1 not taken.
131 init_combo_classes();
18239
18240
2/2
✓ Branch 0 taken 8551680 times.
✓ Branch 1 taken 131 times.
8551811 for(int32_t q = start_combo; q < start_combo+max_combos; ++q)
18241
1/2
✓ Branch 0 taken 8551680 times.
✗ Branch 1 not taken.
8551680 combobuf[q].clear();
18242 131 }
18243
18244
2/2
✓ Branch 0 taken 127 times.
✓ Branch 1 taken 4 times.
131 if(version > 0x192) //Version info
18245 {
18246
2/4
✓ Branch 0 taken 127 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 127 times.
✗ Branch 3 not taken.
127 if(!p_igetw(&section_version,f))
18247 {
18248 return qe_invalid;
18249 }
18250 127 FFCore.quest_format[vCombos] = section_version;
18251
2/4
✓ Branch 0 taken 127 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 127 times.
✗ Branch 3 not taken.
127 if(!p_igetw(&section_cversion,f))
18252 {
18253 return qe_invalid;
18254 }
18255
18256 //section size
18257
2/4
✓ Branch 0 taken 127 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 127 times.
✗ Branch 3 not taken.
127 if(!p_igetl(&dummy,f))
18258 {
18259 return qe_invalid;
18260 }
18261 127 }
18262
18263
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 95 times.
131 if(section_version > 32) //Cleanup time!
18264 {
18265
2/4
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
36 if(!p_igetw(&combos_used,f))
18266 {
18267 return qe_invalid;
18268 }
18269
2/2
✓ Branch 0 taken 231476 times.
✓ Branch 1 taken 36 times.
231512 for(int32_t i=0; i<combos_used; i++)
18270 {
18271
1/2
✓ Branch 0 taken 231476 times.
✗ Branch 1 not taken.
231476 auto ret = readcombo_loop(f,section_version,temp_combo);
18272
1/2
✓ Branch 0 taken 231476 times.
✗ Branch 1 not taken.
231476 if(ret) return ret;
18273
1/2
✓ Branch 0 taken 231476 times.
✗ Branch 1 not taken.
231476 if(i>=start_combo)
18274 {
18275
1/2
✓ Branch 0 taken 231476 times.
✗ Branch 1 not taken.
231476 if(loading_tileset_flags & TILESET_CLEARSCRIPTS)
18276 {
18277 temp_combo.script = 0;
18278 for(int q = 0; q < 8; ++q)
18279 temp_combo.initd[q] = 0;
18280 }
18281
1/2
✓ Branch 0 taken 231476 times.
✗ Branch 1 not taken.
231476 combobuf[i] = temp_combo;
18282 231476 }
18283 231476 }
18284 36 }
18285 else //Call the old function for all old versions
18286 {
18287
1/2
✓ Branch 0 taken 95 times.
✗ Branch 1 not taken.
95 auto ret = readcombos_old(section_version,f,Header,version,build,start_combo,max_combos);
18288
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 95 times.
95 if(ret) return ret; //error, end read
18289 }
18290
18291
1/2
✓ Branch 0 taken 131 times.
✗ Branch 1 not taken.
131 if (should_skip)
18292 return 0;
18293
18294
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 35 times.
131 if(!get_qr(qr_ALLOW_EDITING_COMBO_0))
18295 {
18296 35 combobuf[0].walk = 0xF0;
18297 35 combobuf[0].type = 0;
18298 35 combobuf[0].flag = 0;
18299 35 }
18300
18301
1/2
✓ Branch 0 taken 131 times.
✗ Branch 1 not taken.
131 setup_combo_animations();
18302
1/2
✓ Branch 0 taken 131 times.
✗ Branch 1 not taken.
131 setup_combo_animations2();
18303 131 return 0;
18304 131 }
18305
18306 115 int32_t readcomboaliases(PACKFILE *f, zquestheader *Header, word version, word build)
18307 {
18308 //these are here to bypass compiler warnings about unused arguments
18309 115 Header=Header;
18310 115 version=version;
18311 115 build=build;
18312
18313 int32_t dummy;
18314 115 word sversion=0, c_sversion;
18315
18316 //section version info
18317
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 115 times.
115 if(!p_igetw(&sversion,f))
18318 {
18319 return qe_invalid;
18320 }
18321
18322 115 FFCore.quest_format[vComboAliases] = sversion;
18323
18324 //al_trace("Combo aliases version %d\n", sversion);
18325
1/2
✓ Branch 0 taken 115 times.
✗ Branch 1 not taken.
115 if(!p_igetw(&c_sversion,f))
18326 {
18327 return qe_invalid;
18328 }
18329
18330 //section size
18331
1/2
✓ Branch 0 taken 115 times.
✗ Branch 1 not taken.
115 if(!p_igetl(&dummy,f))
18332 {
18333 return qe_invalid;
18334 }
18335
18336 115 int32_t max_num_combo_aliases = MAXCOMBOALIASES;
18337
18338
2/2
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 77 times.
115 if(sversion < 3) // max saved combo alias' upped from 256 to 2048.
18339 {
18340 77 max_num_combo_aliases = MAX250COMBOALIASES;
18341 77 }
18342
1/2
✓ Branch 0 taken 115 times.
✗ Branch 1 not taken.
115 if(sversion < 2) // max saved combo alias' upped from 256 to 2048.
18343 {
18344 max_num_combo_aliases = OLDMAXCOMBOALIASES;
18345 }
18346
18347
2/2
✓ Branch 0 taken 468992 times.
✓ Branch 1 taken 115 times.
469107 for(int32_t j=0; j<max_num_combo_aliases; j++)
18348 {
18349 byte width,height,mask,tempcset;
18350 int32_t count;
18351 word tempword;
18352 byte tempbyte;
18353
18354
1/2
✓ Branch 0 taken 468992 times.
✗ Branch 1 not taken.
468992 if(!p_igetw(&tempword,f))
18355 {
18356 return qe_invalid;
18357 }
18358
18359 468992 combo_aliases[j].combo = tempword;
18360
18361
1/2
✓ Branch 0 taken 468992 times.
✗ Branch 1 not taken.
468992 if(!p_getc(&tempbyte,f))
18362 {
18363 return qe_invalid;
18364 }
18365
18366 468992 combo_aliases[j].cset = tempbyte;
18367
18368
1/2
✓ Branch 0 taken 468992 times.
✗ Branch 1 not taken.
468992 if(!p_getc(&width,f))
18369 {
18370 return qe_invalid;
18371 }
18372
18373
1/2
✓ Branch 0 taken 468992 times.
✗ Branch 1 not taken.
468992 if(!p_getc(&height,f))
18374 {
18375 return qe_invalid;
18376 }
18377
18378
1/2
✓ Branch 0 taken 468992 times.
✗ Branch 1 not taken.
468992 if(!p_getc(&mask,f))
18379 {
18380 return qe_invalid;
18381 }
18382
18383 468992 count=(width+1)*(height+1)*(comboa_lmasktotal(mask)+1);
18384
18385
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 468992 times.
468992 if(combo_aliases[j].combos != NULL)
18386 {
18387
1/2
✓ Branch 0 taken 468992 times.
✗ Branch 1 not taken.
468992 delete[] combo_aliases[j].combos;
18388 468992 }
18389
18390
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 468992 times.
468992 if(combo_aliases[j].csets != NULL)
18391 {
18392
1/2
✓ Branch 0 taken 468992 times.
✗ Branch 1 not taken.
468992 delete[] combo_aliases[j].csets;
18393 468992 }
18394
18395 468992 combo_aliases[j].width = width;
18396 468992 combo_aliases[j].height = height;
18397 468992 combo_aliases[j].layermask = mask;
18398 468992 combo_aliases[j].combos = new word[count];
18399 468992 combo_aliases[j].csets = new byte[count];
18400
18401
2/2
✓ Branch 0 taken 480701 times.
✓ Branch 1 taken 468992 times.
949693 for(int32_t k=0; k<count; k++)
18402 {
18403
1/2
✓ Branch 0 taken 480701 times.
✗ Branch 1 not taken.
480701 if(!p_igetw(&tempword,f))
18404 {
18405 return qe_invalid;
18406 }
18407
18408 480701 combo_aliases[j].combos[k] = tempword;
18409 480701 }
18410
18411
2/2
✓ Branch 0 taken 480701 times.
✓ Branch 1 taken 468992 times.
949693 for(int32_t k=0; k<count; k++)
18412 {
18413
1/2
✓ Branch 0 taken 480701 times.
✗ Branch 1 not taken.
480701 if(!p_getc(&tempcset,f))
18414 {
18415 return qe_invalid;
18416 }
18417
18418 480701 combo_aliases[j].csets[k] = tempcset;
18419 480701 }
18420 468992 }
18421
18422 //Combo pools!
18423 115 word num_combo_pools = 0;
18424
2/2
✓ Branch 0 taken 79 times.
✓ Branch 1 taken 36 times.
115 if(sversion >= 4)
18425 {
18426
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if(!p_igetw(&num_combo_pools,f))
18427 {
18428 return qe_invalid;
18429 }
18430 36 }
18431
18432
2/2
✓ Branch 0 taken 942080 times.
✓ Branch 1 taken 115 times.
942195 for(combo_pool& pool : combo_pools)
18433 {
18434 942080 pool.clear();
18435 }
18436
18437 115 combo_pool temp_cpool;
18438
2/2
✓ Branch 0 taken 99 times.
✓ Branch 1 taken 115 times.
214 for(word cp = 0; cp < num_combo_pools; ++cp)
18439 {
18440 99 int32_t num_combos_in_pool = 0;
18441
2/4
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 99 times.
✗ Branch 3 not taken.
99 if(!p_igetl(&num_combos_in_pool,f))
18442 {
18443 return qe_invalid;
18444 }
18445
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(num_combos_in_pool < 1) continue; //nothing to read
18446
18447
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 temp_cpool.clear();
18448
18449 int32_t cp_cid; int8_t cp_cs; word cp_quant;
18450
2/2
✓ Branch 0 taken 99 times.
✓ Branch 1 taken 429 times.
528 for(auto q = 0; q < num_combos_in_pool; ++q)
18451 {
18452
2/4
✓ Branch 0 taken 429 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 429 times.
✗ Branch 3 not taken.
429 if(!p_igetl(&cp_cid,f))
18453 {
18454 return qe_invalid;
18455 }
18456
2/4
✓ Branch 0 taken 429 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 429 times.
✗ Branch 3 not taken.
429 if(!p_getc(&cp_cs,f))
18457 {
18458 return qe_invalid;
18459 }
18460
2/4
✓ Branch 0 taken 429 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 429 times.
✗ Branch 3 not taken.
429 if(!p_igetw(&cp_quant,f))
18461 {
18462 return qe_invalid;
18463 }
18464
1/2
✓ Branch 0 taken 429 times.
✗ Branch 1 not taken.
429 temp_cpool.add(cp_cid, cp_cs, cp_quant);
18465 429 }
18466
18467
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 combo_pools[cp] = temp_cpool;
18468 99 }
18469
18470 //Autocombos!
18471 115 word num_combo_autos = 0;
18472
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 86 times.
115 if (sversion >= 5)
18473 {
18474
2/4
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
29 if (!p_igetw(&num_combo_autos, f))
18475 {
18476 return qe_invalid;
18477 }
18478 29 }
18479
18480
2/2
✓ Branch 0 taken 115 times.
✓ Branch 1 taken 942080 times.
942195 for (combo_auto& cauto : combo_autos)
18481 {
18482
1/2
✓ Branch 0 taken 942080 times.
✗ Branch 1 not taken.
942080 cauto.clear(true);
18483 }
18484
18485
1/2
✓ Branch 0 taken 115 times.
✗ Branch 1 not taken.
115 combo_auto temp_cauto;
18486
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 115 times.
139 for (word ca = 0; ca < num_combo_autos; ++ca)
18487 {
18488 byte type;
18489 int32_t display_cid, erase_cid;
18490 byte flags, arg;
18491
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if (!p_getc(&type, f))
18492 {
18493 return qe_invalid;
18494 }
18495
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if (!p_igetl(&display_cid, f))
18496 {
18497 return qe_invalid;
18498 }
18499
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if (!p_igetl(&erase_cid, f))
18500 {
18501 return qe_invalid;
18502 }
18503
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if (!p_getc(&flags, f))
18504 {
18505 return qe_invalid;
18506 }
18507
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if (!p_getc(&arg, f))
18508 {
18509 return qe_invalid;
18510 }
18511 24 int32_t num_combos_in_cauto = 0;
18512
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if (!p_igetl(&num_combos_in_cauto, f))
18513 {
18514 return qe_invalid;
18515 }
18516
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if (num_combos_in_cauto < 1) continue; //nothing to read
18517
18518
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 temp_cauto.clear();
18519
18520
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 temp_cauto.setType(type);
18521
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 temp_cauto.setDisplay(display_cid);
18522
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 temp_cauto.setEraseCombo(erase_cid);
18523
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 temp_cauto.setFlags(flags);
18524
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 temp_cauto.setArg(arg);
18525
18526 int32_t ca_cid; byte ca_ctype; int16_t ca_offset; int16_t ca_engrave_offset;
18527
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 304 times.
328 for (auto q = 0; q < num_combos_in_cauto; ++q)
18528 {
18529
2/4
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 304 times.
✗ Branch 3 not taken.
304 if (!p_getc(&ca_ctype, f))
18530 {
18531 return qe_invalid;
18532 }
18533
2/4
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 304 times.
✗ Branch 3 not taken.
304 if (!p_igetl(&ca_cid, f))
18534 {
18535 return qe_invalid;
18536 }
18537
1/2
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
304 temp_cauto.addEntry(ca_cid, ca_ctype, q, -1);
18538 304 }
18539
18540
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 combo_autos[ca] = temp_cauto;
18541 24 }
18542
18543 115 return 0;
18544 115 }
18545
18546 131 int32_t readcolordata(PACKFILE *f, miscQdata *Misc, word version, word build, word start_cset, word max_csets)
18547 {
18548
2/2
✓ Branch 0 taken 127 times.
✓ Branch 1 taken 4 times.
131 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_colors);
18549
18550 //these are here to bypass compiler warnings about unused arguments
18551 //THE *48 REFERS TO EACH CSET BEING 16 COLORS with 3 VALUES OF RGB (3*16 is 48)
18552 //Capitalized cause it'll save you a headache. -Deedee
18553 131 start_cset=start_cset;
18554 131 max_csets=max_csets;
18555 131 word s_version=0;
18556
18557 miscQdata temp_misc;
18558 131 memcpy(&temp_misc, Misc, sizeof(temp_misc));
18559
18560 byte temp_colordata[48];
18561 char temp_palname[PALNAMESIZE+1];
18562
18563 int32_t dummy;
18564 word palcycles;
18565
18566
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 127 times.
131 if(version > 0x192)
18567 {
18568 //section version info
18569
1/2
✓ Branch 0 taken 127 times.
✗ Branch 1 not taken.
127 if(!p_igetw(&s_version,f))
18570 {
18571 return qe_invalid;
18572 }
18573
18574 127 FFCore.quest_format[vCSets] = s_version;
18575
18576 //al_trace("Color data version %d\n", s_version);
18577
1/2
✓ Branch 0 taken 127 times.
✗ Branch 1 not taken.
127 if(!p_igetw(&dummy,f))
18578 {
18579 return qe_invalid;
18580 }
18581
18582 //section size
18583
1/2
✓ Branch 0 taken 127 times.
✗ Branch 1 not taken.
127 if(!p_igetl(&dummy,f))
18584 {
18585 return qe_invalid;
18586 }
18587 127 }
18588
2/2
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 38 times.
131 if (s_version < 5)
18589 {
18590
3/4
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 89 times.
✓ Branch 2 taken 89 times.
✗ Branch 3 not taken.
93 bool RealOldVerion = ((version < 0x192)||((version == 0x192)&&(build<73)));
18591
18592 //finally... section data
18593 93 int32_t q = 0;
18594 93 int32_t p = -15;
18595
2/2
✓ Branch 0 taken 22320 times.
✓ Branch 1 taken 93 times.
22413 for(int32_t i=0; i<oldpdTOTAL; ++i)
18596 {
18597 22320 memset(temp_colordata, 0, 48);
18598
18599
1/2
✓ Branch 0 taken 22320 times.
✗ Branch 1 not taken.
22320 if(!pfread(temp_colordata,48,f))
18600 {
18601 return qe_invalid;
18602 }
18603
18604
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22320 times.
22320 if (should_skip)
18605 continue;
18606
18607 22320 memcpy(&colordata[q*48], temp_colordata, 48);
18608
18609 22320 ++q;
18610
8/8
✓ Branch 0 taken 20832 times.
✓ Branch 1 taken 1488 times.
✓ Branch 2 taken 1581 times.
✓ Branch 3 taken 19251 times.
✓ Branch 4 taken 186 times.
✓ Branch 5 taken 1395 times.
✓ Branch 6 taken 8 times.
✓ Branch 7 taken 178 times.
22320 if (p > 0 && (p%13)==12 && (i < oldpoSPRITE || !RealOldVerion)) //It's > 0 instead of >= 0 because it should append
18611 {
18612
1/2
✓ Branch 0 taken 1573 times.
✗ Branch 1 not taken.
1573 if (s_version < 5) //Bumping up the size of level palettes
18613 {
18614 1573 memcpy(&colordata[(q)*48], &colordata[1*48], 48);
18615 1573 memcpy(&colordata[(q+1)*48], &colordata[5*48], 48);
18616 1573 memcpy(&colordata[(q+2)*48], &colordata[7*48], 48);
18617 1573 memcpy(&colordata[(q+3)*48], &colordata[8*48], 48);
18618 1573 q+=4;
18619 1573 }
18620 else
18621 {
18622 for(int m = 0; m < 4; ++m)
18623 {
18624 memset(temp_colordata, 0, 48);
18625 if(!pfread(temp_colordata,48,f))
18626 {
18627 return qe_invalid;
18628 }
18629 memcpy(&colordata[q*48], temp_colordata, 48);
18630 ++q;
18631 }
18632 }
18633 1573 }
18634 22320 ++p;
18635 22320 }
18636
18637
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 89 times.
93 if(RealOldVerion)
18638 {
18639
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if (!should_skip)
18640 {
18641 4 memcpy(colordata+(poSPRITE255*48), colordata+((q-30)*48), 30*16*3);
18642 4 memset(colordata+((q-30)*48), 0, ((poSPRITE255-(q-30))*48));
18643 4 memcpy(colordata+((poSPRITE255+11)*48), colordata+((poSPRITE255+10)*48), 48);
18644 4 memcpy(colordata+((poSPRITE255+10)*48), colordata+((poSPRITE255+9)*48), 48);
18645 4 memcpy(colordata+((poSPRITE255+9)*48), colordata+((poSPRITE255+8)*48), 48);
18646 4 memset(colordata+((poSPRITE255+8)*48), 0, 48);
18647 4 }
18648 4 }
18649 else
18650 {
18651 89 memset(temp_colordata, 0, 48);
18652
18653
2/2
✓ Branch 0 taken 278837 times.
✓ Branch 1 taken 89 times.
278926 for(int32_t i=0; i<newpdTOTAL-oldpdTOTAL; ++i)
18654 {
18655
1/2
✓ Branch 0 taken 278837 times.
✗ Branch 1 not taken.
278837 if(!pfread(temp_colordata,48,f))
18656 {
18657 return qe_invalid;
18658 }
18659
18660
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 278837 times.
278837 if (should_skip)
18661 continue;
18662
18663 278837 memcpy(&colordata[q*48], temp_colordata, 48);
18664
18665 278837 ++q;
18666
7/8
✓ Branch 0 taken 278837 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 21449 times.
✓ Branch 3 taken 257388 times.
✓ Branch 4 taken 178 times.
✓ Branch 5 taken 21271 times.
✓ Branch 6 taken 154 times.
✓ Branch 7 taken 24 times.
278837 if (p > 0 && (p%13)==12 && (i < (newpoSPRITE-oldpdTOTAL) || (s_version >= 4))) //It's > 0 instead of >= 0 because it should append
18667 {
18668
1/2
✓ Branch 0 taken 21425 times.
✗ Branch 1 not taken.
21425 if (s_version < 5) //Bumping up the size of level palettes
18669 {
18670 21425 memcpy(&colordata[(q)*48], &colordata[1*48], 48);
18671 21425 memcpy(&colordata[(q+1)*48], &colordata[5*48], 48);
18672 21425 memcpy(&colordata[(q+2)*48], &colordata[7*48], 48);
18673 21425 memcpy(&colordata[(q+3)*48], &colordata[8*48], 48);
18674 21425 q+=4;
18675 21425 }
18676 else
18677 {
18678 for(int m = 0; m < 4; ++m)
18679 {
18680 memset(temp_colordata, 0, 48);
18681 if(!pfread(temp_colordata,48,f))
18682 {
18683 return qe_invalid;
18684 }
18685 memcpy(&colordata[q*48], temp_colordata, 48);
18686 ++q;
18687 }
18688 }
18689 21425 }
18690 278837 ++p;
18691 278837 }
18692
18693
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 77 times.
89 if(s_version < 4)
18694 {
18695
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if (!should_skip)
18696 {
18697 12 memcpy(colordata+(poSPRITE255*48), colordata+((q-30)*48), 30*16*3);
18698 12 memset(colordata+((q-30)*48), 0, ((poSPRITE255-(q-30))*48));
18699 12 }
18700 12 }
18701 else
18702 {
18703
2/2
✓ Branch 0 taken 256256 times.
✓ Branch 1 taken 77 times.
256333 for(int32_t i=0; i<newerpdTOTAL-newpdTOTAL; ++i)
18704 {
18705
1/2
✓ Branch 0 taken 256256 times.
✗ Branch 1 not taken.
256256 if(!pfread(temp_colordata,48,f))
18706 {
18707 return qe_invalid;
18708 }
18709
18710
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 256256 times.
256256 if (should_skip)
18711 continue;
18712
18713 256256 memcpy(&colordata[q*48], temp_colordata, 48);
18714 256256 ++q;
18715
5/6
✓ Branch 0 taken 256256 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 19712 times.
✓ Branch 3 taken 236544 times.
✓ Branch 4 taken 154 times.
✓ Branch 5 taken 19558 times.
256256 if (p > 0 && (p%13)==12 && i < newerpoSPRITE-newpdTOTAL) //It's > 0 instead of >= 0 because it should append
18716 {
18717
1/2
✓ Branch 0 taken 19558 times.
✗ Branch 1 not taken.
19558 if (s_version < 5) //Bumping up the size of level palettes
18718 {
18719 19558 memcpy(&colordata[(q)*48], &colordata[1*48], 48);
18720 19558 memcpy(&colordata[(q+1)*48], &colordata[5*48], 48);
18721 19558 memcpy(&colordata[(q+2)*48], &colordata[7*48], 48);
18722 19558 memcpy(&colordata[(q+3)*48], &colordata[8*48], 48);
18723 19558 q+=4;
18724 19558 }
18725 else
18726 {
18727 for(int m = 0; m < 4; ++m)
18728 {
18729 memset(temp_colordata, 0, 48);
18730 if(!pfread(temp_colordata,48,f))
18731 {
18732 return qe_invalid;
18733 }
18734 memcpy(&colordata[q*48], temp_colordata, 48);
18735 ++q;
18736 }
18737 }
18738 19558 }
18739 256256 ++p;
18740 256256 }
18741
18742 //By this point, q should be about equal to pdTOTAL255. If it isn't, I've fucked up. -Deedee
18743 }
18744 }
18745 93 }
18746 else
18747 {
18748
2/2
✓ Branch 0 taken 332462 times.
✓ Branch 1 taken 38 times.
332500 for(int32_t i=0; i<pdTOTAL255; ++i)
18749 {
18750 332462 memset(temp_colordata, 0, 48);
18751
18752
1/2
✓ Branch 0 taken 332462 times.
✗ Branch 1 not taken.
332462 if(!pfread(temp_colordata,48,f))
18753 {
18754 return qe_invalid;
18755 }
18756
18757 332462 memcpy(&colordata[i*48], temp_colordata, 48);
18758 332462 }
18759 }
18760
18761
3/6
✓ Branch 0 taken 127 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 127 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
131 if((version < 0x192)||((version == 0x192)&&(build<76)))
18762 {
18763
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if (!should_skip)
18764 4 init_palnames();
18765 4 }
18766 else
18767 {
18768 127 int32_t palnamestoread = 0;
18769
18770
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 115 times.
127 if(s_version < 3)
18771 12 palnamestoread = OLDMAXLEVELS;
18772 else
18773 115 palnamestoread = 512;
18774
18775
2/2
✓ Branch 0 taken 61952 times.
✓ Branch 1 taken 127 times.
62079 for(int32_t i=0; i<palnamestoread; ++i)
18776 {
18777
1/2
✓ Branch 0 taken 61952 times.
✗ Branch 1 not taken.
61952 if(!p_getstr(temp_palname,PALNAMESIZE,f))
18778 {
18779 return qe_invalid;
18780 }
18781
18782
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 61952 times.
61952 if (!should_skip)
18783 61952 memcpy(palnames[i], temp_palname, PALNAMESIZE);
18784 61952 }
18785
18786
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 127 times.
127 if (should_skip)
18787 return 0;
18788
18789
2/2
✓ Branch 0 taken 3072 times.
✓ Branch 1 taken 127 times.
3199 for(int32_t i=palnamestoread; i<MAXLEVELS; i++)
18790 {
18791 3072 memset(palnames[i], 0, PALNAMESIZE);
18792 3072 }
18793 }
18794
18795
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 127 times.
131 if(version > 0x192)
18796 {
18797
2/2
✓ Branch 0 taken 32512 times.
✓ Branch 1 taken 127 times.
32639 for(int32_t i=0; i<256; i++)
18798 {
18799
2/2
✓ Branch 0 taken 97536 times.
✓ Branch 1 taken 32512 times.
130048 for(int32_t j=0; j<3; j++)
18800 {
18801 97536 temp_misc.cycles[i][j].first=0;
18802 97536 temp_misc.cycles[i][j].count=0;
18803 97536 temp_misc.cycles[i][j].speed=0;
18804 97536 }
18805 32512 }
18806
18807
1/2
✓ Branch 0 taken 127 times.
✗ Branch 1 not taken.
127 if(!p_igetw(&palcycles,f))
18808 {
18809 return qe_invalid;
18810 }
18811
18812
2/4
✓ Branch 0 taken 127 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 127 times.
127 if (!(palcycles >= 0 && palcycles <= NUM_PAL_CYCLES))
18813 {
18814 return qe_invalid;
18815 }
18816
18817
2/2
✓ Branch 0 taken 3576 times.
✓ Branch 1 taken 127 times.
3703 for(int32_t i=0; i<palcycles; i++)
18818 {
18819
2/2
✓ Branch 0 taken 10728 times.
✓ Branch 1 taken 3576 times.
14304 for(int32_t j=0; j<3; j++)
18820 {
18821
1/2
✓ Branch 0 taken 10728 times.
✗ Branch 1 not taken.
10728 if(!p_getc(&temp_misc.cycles[i][j].first,f))
18822 {
18823 return qe_invalid;
18824 }
18825 10728 }
18826
18827
2/2
✓ Branch 0 taken 10728 times.
✓ Branch 1 taken 3576 times.
14304 for(int32_t j=0; j<3; j++)
18828 {
18829
1/2
✓ Branch 0 taken 10728 times.
✗ Branch 1 not taken.
10728 if(!p_getc(&temp_misc.cycles[i][j].count,f))
18830 {
18831 return qe_invalid;
18832 }
18833 10728 }
18834
18835
2/2
✓ Branch 0 taken 10728 times.
✓ Branch 1 taken 3576 times.
14304 for(int32_t j=0; j<3; j++)
18836 {
18837
1/2
✓ Branch 0 taken 10728 times.
✗ Branch 1 not taken.
10728 if(!p_getc(&temp_misc.cycles[i][j].speed,f))
18838 {
18839 return qe_invalid;
18840 }
18841 10728 }
18842 3576 }
18843
18844 127 memcpy(Misc, &temp_misc, sizeof(temp_misc));
18845 127 }
18846
18847 131 return 0;
18848 131 }
18849
18850 131 int32_t readtiles(PACKFILE *f, tiledata *buf, zquestheader *Header, word version, word build, word start_tile, int32_t max_tiles, bool from_init)
18851 {
18852
2/2
✓ Branch 0 taken 127 times.
✓ Branch 1 taken 4 times.
131 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_tiles);
18853
18854 131 int32_t tiles_used=0;
18855 131 word section_version = 0;
18856 131 word section_cversion = 0;
18857 131 int32_t section_size= 0;
18858 131 byte *temp_tile = new byte[tilesize(tf32Bit)];
18859
18860 //Tile Expansion
18861 //if ( version >= 0x254 && build >= 41 )
18862
3/4
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 38 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 93 times.
131 if (version < 0x254 && build < 41)
18863 {
18864 //al_trace("Build was < 41 when reading tiles\n");
18865 93 max_tiles = ZC250MAXTILES;
18866 93 }
18867
18868 //al_trace("Max Tiles: %d\n", max_tiles);
18869
18870
2/6
✓ Branch 0 taken 131 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 131 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
131 if(Header!=NULL&&(!Header->data_flags[ZQ_TILES]&&!from_init)) //keep for old quests
18871 {
18872 if(!init_tiles(true, Header))
18873 {
18874 al_trace("Unable to initialize tiles\n");
18875 }
18876
18877 delete[] temp_tile;
18878 temp_tile=NULL;
18879 return 0;
18880 }
18881 else
18882 {
18883
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 127 times.
131 if(version > 0x192)
18884 {
18885 //section version info
18886
1/2
✓ Branch 0 taken 127 times.
✗ Branch 1 not taken.
127 if(!p_igetw(&section_version,f))
18887 {
18888 delete[] temp_tile;
18889 return qe_invalid;
18890 }
18891
18892 127 FFCore.quest_format[vTiles] = section_version;
18893
18894
1/2
✓ Branch 0 taken 127 times.
✗ Branch 1 not taken.
127 if(!p_igetw(&section_cversion,f))
18895 {
18896 delete[] temp_tile;
18897 return qe_invalid;
18898 }
18899
18900 //section size
18901
1/2
✓ Branch 0 taken 127 times.
✗ Branch 1 not taken.
127 if(!p_igetl(&section_size,f))
18902 {
18903 delete[] temp_tile;
18904 return qe_invalid;
18905 }
18906 127 }
18907
18908 //if ( build < 41 )
18909 //{
18910 // tiles_used = ZC250MAXTILES;
18911 //}
18912
18913
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 131 times.
131 if(version < 0x174)
18914 {
18915 tiles_used=TILES_PER_PAGE*4;
18916 } //no expanded tile space
18917
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 127 times.
131 else if(version < 0x191)
18918 {
18919 4 tiles_used=OLDMAXTILES;
18920 4 }
18921 else
18922 {
18923 //finally... section data
18924
3/4
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 89 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 38 times.
127 if ( version >= 0x254 && build >= 41 ) //read and write the size of tiles_used properly
18925 {
18926
1/2
✓ Branch 0 taken 38 times.
✗ Branch 1 not taken.
38 if(!p_igetl(&tiles_used,f))
18927 {
18928 delete[] temp_tile;
18929 return qe_invalid;
18930 }
18931 38 }
18932 else
18933 {
18934
1/2
✓ Branch 0 taken 89 times.
✗ Branch 1 not taken.
89 if(!p_igetw(&tiles_used,f))
18935 {
18936 delete[] temp_tile;
18937 return qe_invalid;
18938 }
18939 }
18940 }
18941
18942
1/2
✓ Branch 0 taken 131 times.
✗ Branch 1 not taken.
131 tiles_used=zc_min(tiles_used, max_tiles);
18943
18944 //if ( version < 0x254 || ( version >= 0x254 && build < 41 )) //don't do this, it crashes ZQuest. -Z
18945 //if ( version < 0x254 && build < 41 )
18946
3/6
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 93 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 38 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
131 if ( version < 0x254 || (version == 0x254 && build < 41) )
18947 //if ( build < 41 )
18948 {
18949
1/2
✓ Branch 0 taken 93 times.
✗ Branch 1 not taken.
93 tiles_used=zc_min(tiles_used, ZC250MAXTILES-start_tile);
18950 93 }
18951 else //2.55
18952 {
18953
1/2
✓ Branch 0 taken 38 times.
✗ Branch 1 not taken.
38 tiles_used = zc_min(tiles_used,NEWMAXTILES-start_tile);
18954 }
18955
18956 //if ( section_version > 1 ) tiles_used = NEWMAXTILES;
18957
18958 //al_trace("tiles_used = %d\n", tiles_used);
18959
18960
2/2
✓ Branch 0 taken 3574818 times.
✓ Branch 1 taken 131 times.
3574949 for(int32_t i=0; i<tiles_used; ++i)
18961 {
18962 3574818 byte format=tf4Bit;
18963 3574818 memset(temp_tile, 0, tilesize(tf32Bit));
18964
18965
3/6
✓ Branch 0 taken 630780 times.
✓ Branch 1 taken 2944038 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 630780 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
3574818 if((version>0x211)||((version==0x211)&&(build>4)))
18966 {
18967
1/2
✓ Branch 0 taken 2944038 times.
✗ Branch 1 not taken.
2944038 if(!p_getc(&format,f))
18968 {
18969 delete[] temp_tile;
18970 return qe_invalid;
18971 }
18972 2944038 }
18973
4/4
✓ Branch 0 taken 1394484 times.
✓ Branch 1 taken 2180334 times.
✓ Branch 2 taken 644559 times.
✓ Branch 3 taken 749925 times.
3574818 if(section_version > 2 && !format)
18974 {
18975 749925 reset_tile(buf,start_tile+i,tf4Bit);
18976 749925 continue;
18977 }
18978
18979
2/2
✓ Branch 0 taken 2779939 times.
✓ Branch 1 taken 44954 times.
2824893 int size = format == tf4Bit ? 128 : tilesize(format);
18980
1/2
✓ Branch 0 taken 2824893 times.
✗ Branch 1 not taken.
2824893 if(!pfread(temp_tile,size,f))
18981 {
18982 delete[] temp_tile;
18983 return qe_invalid;
18984 }
18985
18986
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2824893 times.
2824893 if (should_skip)
18987 continue;
18988
18989 2824893 buf[start_tile+i].format=format;
18990
18991
1/2
✓ Branch 0 taken 2824893 times.
✗ Branch 1 not taken.
2824893 if(buf[start_tile+i].data)
18992 {
18993 2824893 free(buf[start_tile+i].data);
18994 2824893 buf[start_tile+i].data=NULL;
18995 2824893 }
18996
18997 2824893 buf[start_tile+i].data=(byte *)malloc(tilesize(buf[start_tile+i].format));
18998
18999
2/2
✓ Branch 0 taken 2779939 times.
✓ Branch 1 taken 44954 times.
2824893 if (format == tf4Bit)
19000 {
19001 byte temp[256];
19002 2779939 byte *si = temp_tile + 128;
19003 2779939 byte *di = temp + 256;
19004
19005
2/2
✓ Branch 0 taken 355832192 times.
✓ Branch 1 taken 2779939 times.
358612131 for(int i=127; i>=0; --i)
19006 {
19007 355832192 (*(--di)) = (*(--si)) >> 4;
19008 355832192 (*(--di)) = (*si) & 15;
19009 355832192 }
19010
19011 2779939 memcpy(buf[start_tile+i].data,temp,256);
19012 2779939 }
19013 else
19014 {
19015 44954 memcpy(buf[start_tile+i].data,temp_tile,tilesize(buf[start_tile+i].format));
19016 }
19017 2824893 }
19018 }
19019
19020
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 131 times.
131 if (should_skip)
19021 return 0;
19022
19023
2/2
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 93 times.
131 if ( section_version < 2 ) //write blank tile data --check s_version with this again instead?
19024 {
19025 //al_trace("Writing blank tile data to new tiles for build < 41\n");
19026
2/2
✓ Branch 0 taken 13855140 times.
✓ Branch 1 taken 93 times.
13855233 for ( int32_t q = ZC250MAXTILES; q < NEWMAXTILES; ++q )
19027 {
19028
19029 //memcpy(buf[q].data,temp_tile,tilesize(buf[q].format));
19030 13855140 reset_tile(buf,q,tf4Bit);
19031
19032
19033 /*
19034
19035 byte tempbyte;
19036 for(int32_t i=0; i<tilesize(tf4Bit); i++)
19037 {
19038 tempbyte=buf[ZC250MAXTILES-1].data[i];
19039 buf[q].data[i] = tempbyte;
19040 }
19041 //int32_t temp = tempbyte=buf[130].data[i];
19042 //buf[q].data = buf[ZC250MAXTILES-1].data;
19043 */
19044 //reset_tile(buf,q,tf4Bit);
19045 13855140 }
19046
19047 93 }
19048
19049
4/6
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 93 times.
✓ Branch 2 taken 38 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 38 times.
131 if ( version < 0x254 || ( version >= 0x254 && build < 41 ))
19050 {
19051
2/2
✓ Branch 0 taken 4121646 times.
✓ Branch 1 taken 93 times.
4121739 for(int32_t i=start_tile+tiles_used; i<max_tiles; ++i)
19052 {
19053 //al_trace("Resetting tiles for ZC250MAXTILES, iteration: %d\n", i);
19054 4121646 reset_tile(buf,i,tf4Bit);
19055 4121646 }
19056 93 }
19057 else
19058 {
19059
2/2
✓ Branch 0 taken 6547896 times.
✓ Branch 1 taken 38 times.
6547934 for(int32_t i=start_tile+tiles_used; i<max_tiles; ++i)
19060 {
19061 //al_trace("Resetting tiles for build 41+\n");
19062 6547896 reset_tile(buf,i,tf4Bit);
19063 6547896 }
19064 }
19065
19066
3/6
✓ Branch 0 taken 127 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 127 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
131 if((version < 0x192)|| ((version == 0x192)&&(build<186)))
19067 {
19068
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(get_qr(qr_BSZELDA)) //
19069 {
19070 byte tempbyte;
19071 int32_t floattile=wpnsbuf[iwSwim].tile;
19072
19073 for(int32_t i=0; i<tilesize(tf4Bit); i++) //BSZelda tiles are out of order //does this include swim tiles?
19074 {
19075 tempbyte=buf[23].data[i];
19076 buf[23].data[i]=buf[24].data[i];
19077 buf[24].data[i]=buf[25].data[i];
19078 buf[25].data[i]=buf[26].data[i];
19079 buf[26].data[i]=tempbyte;
19080 }
19081 //swim tiles are out of order, too, but nobody cared? -Z
19082 for(int32_t i=0; i<tilesize(tf4Bit); i++)
19083 {
19084 tempbyte=buf[floattile+11].data[i];
19085 buf[floattile+11].data[i]=buf[floattile+12].data[i];
19086 buf[floattile+12].data[i]=tempbyte;
19087 }
19088 }
19089 4 }
19090
19091
3/6
✓ Branch 0 taken 115 times.
✓ Branch 1 taken 16 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 115 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
131 if((version < 0x211)||((version == 0x211)&&(build<7))) //Goriya tiles are out of order
19092 {
19093
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 4 times.
16 if(!get_qr(qr_NEWENEMYTILES))
19094 {
19095 byte tempbyte;
19096
19097
2/2
✓ Branch 0 taken 1024 times.
✓ Branch 1 taken 4 times.
1028 for(int32_t i=0; i<tilesize(tf4Bit); i++)
19098 {
19099 1024 tempbyte=buf[130].data[i];
19100 1024 buf[130].data[i]=buf[132].data[i];
19101 1024 buf[132].data[i]=tempbyte;
19102
19103 1024 tempbyte=buf[131].data[i];
19104 1024 buf[131].data[i]=buf[133].data[i];
19105 1024 buf[133].data[i]=tempbyte;
19106 1024 }
19107 4 }
19108 16 }
19109
19110 131 al_trace("Registering blank tiles\n");
19111 131 register_blank_tiles();
19112
19113 //memset(temp_tile, 0, tilesize(tf32Bit));
19114
1/2
✓ Branch 0 taken 131 times.
✗ Branch 1 not taken.
131 delete[] temp_tile;
19115 131 temp_tile=NULL;
19116 131 return 0;
19117 131 }
19118
19119 131 int32_t readtunes(PACKFILE *f, zquestheader *Header, zctune *tunes /*zcmidi_ *midis*/)
19120 {
19121
2/2
✓ Branch 0 taken 127 times.
✓ Branch 1 taken 4 times.
131 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_midis);
19122
19123 static byte fake_midi_flags[32];
19124
19125
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 131 times.
131 byte *mf=should_skip ? fake_midi_flags : midi_flags;
19126 int32_t dummy;
19127 word dummy2;
19128 // zcmidi_ temp_midi;
19129 int32_t tunes_to_read;
19130 131 int32_t tune_count=0;
19131 131 word section_version=0;
19132 131 zctune temp;
19133
19134
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 127 times.
131 if(Header->zelda_version < 0x193)
19135 {
19136 // mf=Header->data_flags+ZQ_MIDIS2;
19137
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
4 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<178)))
19138 {
19139 4 tunes_to_read=MAXCUSTOMMIDIS192b177;
19140 4 }
19141 else
19142 {
19143 tunes_to_read=MAXCUSTOMTUNES;
19144 }
19145 4 }
19146 else
19147 {
19148 //section version info
19149
1/2
✓ Branch 0 taken 127 times.
✗ Branch 1 not taken.
127 if(!p_igetw(&section_version,f))
19150 {
19151 return qe_invalid;
19152 }
19153
19154
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 127 times.
127 if (!should_skip)
19155 127 FFCore.quest_format[vMIDIs] = section_version;
19156
19157 //al_trace("Tunes version %d\n", section_version);
19158
1/2
✓ Branch 0 taken 127 times.
✗ Branch 1 not taken.
127 if(!p_igetw(&dummy2,f))
19159 {
19160 return qe_invalid;
19161 }
19162
19163 //section size
19164
1/2
✓ Branch 0 taken 127 times.
✗ Branch 1 not taken.
127 if(!p_igetl(&dummy,f))
19165 {
19166 return qe_invalid;
19167 }
19168
19169 //finally... section data
19170
1/2
✓ Branch 0 taken 127 times.
✗ Branch 1 not taken.
127 if(!pfread(midi_flags,sizeof(midi_flags),f))
19171 {
19172 return qe_invalid;
19173 }
19174
19175 127 tunes_to_read=MAXCUSTOMTUNES;
19176 }
19177
19178
2/2
✓ Branch 0 taken 33012 times.
✓ Branch 1 taken 131 times.
33143 for(int32_t i=0; i<MAXCUSTOMTUNES; ++i)
19179 {
19180
2/2
✓ Branch 0 taken 2304 times.
✓ Branch 1 taken 30708 times.
33012 if(get_bit(mf, i))
19181 {
19182 2304 ++tune_count;
19183 2304 }
19184 33012 }
19185
19186
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 131 times.
131 if (!should_skip)
19187 131 reset_tunes(tunes); //reset_midis(midis);
19188
19189
2/2
✓ Branch 0 taken 32132 times.
✓ Branch 1 taken 131 times.
32263 for(int32_t i=0; i<tunes_to_read; i++)
19190 {
19191 32132 temp.clear(); //memset(&temp_midi,0,sizeof(zcmidi_));
19192
19193
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32132 times.
32132 if (!should_skip)
19194 32132 tunes[i].reset(); // reset_midi(midis+i);
19195
19196
2/2
✓ Branch 0 taken 29828 times.
✓ Branch 1 taken 2304 times.
32132 if(get_bit(mf,i))
19197 {
19198
2/2
✓ Branch 0 taken 717 times.
✓ Branch 1 taken 1587 times.
2304 if(section_version < 4)
19199 {
19200
1/2
✓ Branch 0 taken 717 times.
✗ Branch 1 not taken.
717 if(!p_getstr(temp.title,20,f))
19201 {
19202 return qe_invalid;
19203 }
19204 717 }
19205 else
19206 {
19207
1/2
✓ Branch 0 taken 1587 times.
✗ Branch 1 not taken.
1587 if(!p_getstr(temp.title,sizeof(temp.title)-1,f))
19208 {
19209 return qe_invalid;
19210 }
19211 }
19212
19213
1/2
✓ Branch 0 taken 2304 times.
✗ Branch 1 not taken.
2304 if(!p_igetl(&temp.start,f))
19214 {
19215 return qe_invalid;
19216 }
19217
19218
1/2
✓ Branch 0 taken 2304 times.
✗ Branch 1 not taken.
2304 if(!p_igetl(&temp.loop_start,f))
19219 {
19220 return qe_invalid;
19221 }
19222
19223
1/2
✓ Branch 0 taken 2304 times.
✗ Branch 1 not taken.
2304 if(!p_igetl(&temp.loop_end,f))
19224 {
19225 return qe_invalid;
19226 }
19227
19228
1/2
✓ Branch 0 taken 2304 times.
✗ Branch 1 not taken.
2304 if(!p_igetw(&temp.loop,f))
19229 {
19230 return qe_invalid;
19231 }
19232
19233
1/2
✓ Branch 0 taken 2304 times.
✗ Branch 1 not taken.
2304 if(!p_igetw(&temp.volume,f))
19234 {
19235 return qe_invalid;
19236 }
19237
19238
2/2
✓ Branch 0 taken 2226 times.
✓ Branch 1 taken 78 times.
2304 if(Header->zelda_version < 0x193)
19239 {
19240
1/2
✓ Branch 0 taken 78 times.
✗ Branch 1 not taken.
78 if(!p_igetl(&dummy,f))
19241 {
19242 return qe_invalid;
19243 }
19244 78 }
19245
19246
2/2
✓ Branch 0 taken 717 times.
✓ Branch 1 taken 1587 times.
2304 if(section_version >= 3)
19247 {
19248
1/2
✓ Branch 0 taken 1587 times.
✗ Branch 1 not taken.
1587 if(!pfread(&temp.flags,sizeof(temp.flags),f))
19249 {
19250 return qe_invalid;
19251 }
19252 1587 }
19253
19254
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2304 times.
2304 if (!should_skip)
19255 2304 tunes[i].copyfrom(temp); // memcpy(&midis[i], &temp_midi, sizeof(zcmidi_));
19256
19257
2/2
✓ Branch 0 taken 717 times.
✓ Branch 1 taken 1587 times.
2304 if(section_version < 2) //= 1 || (Header->zelda_version < 0x211) || (Header->zelda_version == 0x211 && Header->build < 18))
19258 {
19259
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 717 times.
717 if (should_skip)
19260 {
19261 if (read_midi(f)==NULL)
19262 {
19263 return qe_invalid;
19264 }
19265
19266 continue;
19267 }
19268
19269 // old format - a midi is a midi
19270
1/2
✓ Branch 0 taken 717 times.
✗ Branch 1 not taken.
717 if((tunes[i].data=read_midi(f))==NULL)
19271 {
19272 return qe_invalid;
19273 }
19274
19275 //yes you can do this. Isn't the ? operator awesome? :)
19276 717 tunes[i].format = MFORMAT_MIDI;
19277 717 }
19278 else
19279 {
19280 // 'midi' could be midi or nes, gb, ... music
19281
1/2
✓ Branch 0 taken 1587 times.
✗ Branch 1 not taken.
1587 if(!pfread(&tunes[i].format,sizeof(tunes[i].format),f))
19282 {
19283 return qe_invalid;
19284 }
19285
19286 1587 zctune *ptr = &tunes[i];
19287
19288
1/2
✓ Branch 0 taken 1587 times.
✗ Branch 1 not taken.
1587 switch(temp.format)
19289 {
19290 case MFORMAT_MIDI:
19291
1/2
✓ Branch 0 taken 1587 times.
✗ Branch 1 not taken.
1587 if((ptr->data=read_midi(f))==NULL)
19292 {
19293 return qe_invalid;
19294 }
19295
19296 1587 break;
19297
19298 default:
19299 return qe_invalid;
19300 break;
19301 }
19302 }
19303 2304 }
19304 32132 }
19305
19306 131 return 0;
19307 131 }
19308
19309 131 int32_t readcheatcodes(PACKFILE *f, zquestheader *Header)
19310 {
19311
2/2
✓ Branch 0 taken 127 times.
✓ Branch 1 taken 4 times.
131 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_cheats);
19312
19313 int32_t dummy;
19314 ZCHEATS tempzcheats;
19315 131 char temp_use_cheats=1;
19316 131 memset(&tempzcheats, 0, sizeof(tempzcheats));
19317 131 word s_version = 0;
19318
19319
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 127 times.
131 if(Header->zelda_version > 0x192)
19320 {
19321 //section version info
19322
1/2
✓ Branch 0 taken 127 times.
✗ Branch 1 not taken.
127 if(!p_igetw(&s_version,f))
19323 {
19324 return qe_invalid;
19325 }
19326
19327 127 FFCore.quest_format[vCheats] = s_version;
19328 //al_trace("Cheats version %d\n", dummy);
19329
1/2
✓ Branch 0 taken 127 times.
✗ Branch 1 not taken.
127 if(!p_igetw(&dummy,f))
19330 {
19331 return qe_invalid;
19332 }
19333
19334 //section size
19335
1/2
✓ Branch 0 taken 127 times.
✗ Branch 1 not taken.
127 if(!p_igetl(&dummy,f))
19336 {
19337 return qe_invalid;
19338 }
19339
19340 //finally... section data
19341
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 127 times.
127 if(!p_getc(&temp_use_cheats,f))
19342 {
19343 return qe_invalid;
19344 }
19345 127 }
19346
19347
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 131 times.
131 if(Header->data_flags[ZQ_CHEATS2])
19348 {
19349
1/2
✓ Branch 0 taken 131 times.
✗ Branch 1 not taken.
131 if(!p_igetl(&tempzcheats.flags,f))
19350 {
19351 return qe_invalid;
19352 }
19353
19354
1/2
✓ Branch 0 taken 131 times.
✗ Branch 1 not taken.
131 if(!pfread(&tempzcheats.codes, sizeof(tempzcheats.codes),f))
19355 {
19356 return qe_invalid;
19357 }
19358 131 }
19359
19360
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 131 times.
131 if (should_skip)
19361 return 0;
19362
19363 131 memcpy(&zcheats, &tempzcheats, sizeof(tempzcheats));
19364 131 Header->data_flags[ZQ_CHEATS2]=temp_use_cheats;
19365
19366 131 return 0;
19367 131 }
19368
19369 102 int32_t readinitdata_old(PACKFILE *f, zquestheader *Header, word s_version, word s_cversion, zinitdata& temp_zinit)
19370 {
19371
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 98 times.
102 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_initdata);
19372
19373 int32_t dummy;
19374 byte padding, tempbyte;
19375
19376 // Legacy item properties (now integrated into itemdata)
19377 byte sword_hearts[4];
19378 byte beam_hearts[4];
19379 102 byte beam_percent=0;
19380 word beam_power[4];
19381 102 byte hookshot_length=99;
19382 102 byte hookshot_links=100;
19383 102 byte longshot_length=99;
19384 102 byte longshot_links=100;
19385 102 byte moving_fairy_hearts=3;
19386 102 byte moving_fairy_heart_percent=0;
19387 102 byte stationary_fairy_hearts=3;
19388 102 byte stationary_fairy_heart_percent=0;
19389 102 byte moving_fairy_magic=0;
19390 102 byte moving_fairy_magic_percent=0;
19391 102 byte stationary_fairy_magic=0;
19392 102 byte stationary_fairy_magic_percent=0;
19393 102 byte blue_potion_hearts=100;
19394 102 byte blue_potion_heart_percent=1;
19395 102 byte red_potion_hearts=100;
19396 102 byte red_potion_heart_percent=1;
19397 102 byte blue_potion_magic=100;
19398 102 byte blue_potion_magic_percent=1;
19399 102 byte red_potion_magic=100;
19400 102 byte red_potion_magic_percent=1;
19401
19402 102 byte bomb_ratio = 4;
19403
19404 102 subscr_mode = 0;
19405
19406 /* HIGHLY UNORTHODOX UPDATING THING, by L
19407 * This fixes quests made before revision 277 (such as the 'Lost Isle Build'),
19408 * where the speed of Pols Voice changed. It also coincided with V_INITDATA
19409 * changing from 13 to 14.
19410 */
19411
2/2
✓ Branch 0 taken 86 times.
✓ Branch 1 taken 16 times.
102 if(s_version < 14)
19412 16 fixpolsvoice=true;
19413
19414 /* End highly unorthodox updating thing */
19415
19416
4/4
✓ Branch 0 taken 86 times.
✓ Branch 1 taken 16 times.
✓ Branch 2 taken 75 times.
✓ Branch 3 taken 11 times.
102 if(s_version >= 15 && get_bit(deprecated_rules, 27)) // The int16_t-lived rule, qr_JUMPHEROLAYER3
19417 11 temp_zinit.jump_hero_layer_threshold=0;
19418
19419
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 86 times.
102 if(s_version >= 10)
19420 {
19421 char temp;
19422
19423 //new-style items
19424
2/2
✓ Branch 0 taken 22016 times.
✓ Branch 1 taken 86 times.
22102 for(int32_t j=0; j<256; j++)
19425 {
19426
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22016 times.
22016 if(!p_getc(&temp,f))
19427 return qe_invalid;
19428
19429 22016 temp_zinit.set_item(j, temp != 0);
19430 22016 }
19431 86 }
19432
19433
3/6
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 98 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
102 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>26)))
19434 {
19435 char temp;
19436
19437 //finally... section data
19438
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 98 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
98 if((Header->zelda_version > 0x192)||
19439 //new only
19440 ((Header->zelda_version == 0x192)&&(Header->build>173)))
19441 {
19442 //OLD-style items... sigh
19443
2/2
✓ Branch 0 taken 86 times.
✓ Branch 1 taken 12 times.
98 if(s_version < 10)
19444 {
19445
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_getc(&temp,f))
19446 {
19447 return qe_invalid;
19448 }
19449
19450 12 temp_zinit.set_item(iRaft, temp != 0);
19451
19452
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_getc(&temp,f))
19453 {
19454 return qe_invalid;
19455 }
19456
19457 12 temp_zinit.set_item(iLadder, temp != 0);
19458
19459
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_getc(&temp,f))
19460 {
19461 return qe_invalid;
19462 }
19463
19464 12 temp_zinit.set_item(iBook, temp != 0);
19465
19466
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_getc(&temp,f))
19467 {
19468 return qe_invalid;
19469 }
19470
19471 12 temp_zinit.set_item(iMKey, temp != 0);
19472
19473
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_getc(&temp,f))
19474 {
19475 return qe_invalid;
19476 }
19477
19478 12 temp_zinit.set_item(iFlippers, temp != 0);
19479
19480
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_getc(&temp,f))
19481 {
19482 return qe_invalid;
19483 }
19484
19485 12 temp_zinit.set_item(iBoots, temp != 0);
19486 12 }
19487 98 }
19488
19489
2/2
✓ Branch 0 taken 86 times.
✓ Branch 1 taken 12 times.
98 if(s_version < 10)
19490 {
19491 char tempring, tempsword, tempshield, tempwallet, tempbracelet, tempamulet, tempbow;
19492
19493
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_getc(&tempring,f))
19494 {
19495 return qe_invalid;
19496 }
19497
19498
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_getc(&tempsword,f))
19499 {
19500 return qe_invalid;
19501 }
19502
19503
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_getc(&tempshield,f))
19504 {
19505 return qe_invalid;
19506 }
19507
19508
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_getc(&tempwallet,f))
19509 {
19510 return qe_invalid;
19511 }
19512
19513
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_getc(&tempbracelet,f))
19514 {
19515 return qe_invalid;
19516 }
19517
19518
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_getc(&tempamulet,f))
19519 {
19520 return qe_invalid;
19521 }
19522
19523
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_getc(&tempbow,f))
19524 {
19525 return qe_invalid;
19526 }
19527
19528 //old only
19529
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12 if((Header->zelda_version == 0x192)&&(Header->build<174))
19530 {
19531 tempring=(tempring)?(1<<(tempring-1)):0;
19532 tempsword=(tempsword)?(1<<(tempsword-1)):0;
19533 tempshield=(tempshield)?(1<<(tempshield-1)):0;
19534 tempwallet=(tempwallet)?(1<<(tempwallet-1)):0;
19535 tempbracelet=(tempbracelet)?(1<<(tempbracelet-1)):0;
19536 tempamulet=(tempamulet)?(1<<(tempamulet-1)):0;
19537 tempbow=(tempbow)?(1<<(tempbow-1)):0;
19538 }
19539
19540 //rings start at level 2... wtf
19541 //account for this -DD
19542 12 tempring <<= 1;
19543 12 addOldStyleFamily(&temp_zinit, itemsbuf, itype_ring, tempring);
19544 12 addOldStyleFamily(&temp_zinit, itemsbuf, itype_sword, tempsword);
19545 12 addOldStyleFamily(&temp_zinit, itemsbuf, itype_shield, tempshield);
19546 12 addOldStyleFamily(&temp_zinit, itemsbuf, itype_wallet, tempwallet);
19547 //bracelet ALSO starts at level 2 :-( -DD
19548 12 tempbracelet<<=1;
19549 12 addOldStyleFamily(&temp_zinit, itemsbuf, itype_bracelet, tempbracelet);
19550 12 addOldStyleFamily(&temp_zinit, itemsbuf, itype_amulet, tempamulet);
19551 12 addOldStyleFamily(&temp_zinit, itemsbuf, itype_bow, tempbow);
19552
19553 //new only
19554
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12 if((Header->zelda_version == 0x192)&&(Header->build>173))
19555 {
19556 for(int32_t q=0; q<32; q++)
19557 {
19558 if(!p_getc(&padding,f))
19559 {
19560 return qe_invalid;
19561 }
19562 }
19563 }
19564
19565 char tempcandle, tempboomerang, temparrow, tempwhistle;
19566
19567
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_getc(&tempcandle,f))
19568 {
19569 return qe_invalid;
19570 }
19571
19572
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_getc(&tempboomerang,f))
19573 {
19574 return qe_invalid;
19575 }
19576
19577
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_getc(&temparrow,f))
19578 {
19579 return qe_invalid;
19580 }
19581
19582
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_getc(&temp,f))
19583 {
19584 return qe_invalid;
19585 }
19586
19587 12 addOldStyleFamily(&temp_zinit, itemsbuf, itype_potion, temp);
19588
19589
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_getc(&tempwhistle,f))
19590 {
19591 return qe_invalid;
19592 }
19593
19594 //old only
19595
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12 if((Header->zelda_version == 0x192)&&(Header->build<174))
19596 {
19597 tempcandle=(tempcandle)?(1<<(tempcandle-1)):0;
19598 tempboomerang=(tempboomerang)?(1<<(tempboomerang-1)):0;
19599 temparrow=(temparrow)?(1<<(temparrow-1)):0;
19600 tempwhistle=(tempwhistle)?(1<<(tempwhistle-1)):0;
19601 }
19602
19603 12 addOldStyleFamily(&temp_zinit, itemsbuf, itype_candle, tempcandle);
19604 12 addOldStyleFamily(&temp_zinit, itemsbuf, itype_brang, tempboomerang);
19605 12 addOldStyleFamily(&temp_zinit, itemsbuf, itype_arrow, temparrow);
19606 12 addOldStyleFamily(&temp_zinit, itemsbuf, itype_whistle, tempwhistle);
19607 //What about the potion...?
19608
19609 12 }
19610
19611
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 89 times.
98 if(s_version < 29)
19612 {
19613 //Oh sure, stick these IN THE MIDDLE OF THE ITEMS, just to make me want
19614 //to jab out my eye...
19615
1/2
✓ Branch 0 taken 89 times.
✗ Branch 1 not taken.
89 if(!p_getc(&padding,f))
19616 return qe_invalid;
19617 89 temp_zinit.counter[crBOMBS] = padding;
19618
19619
1/2
✓ Branch 0 taken 89 times.
✗ Branch 1 not taken.
89 if(!p_getc(&padding,f))
19620 return qe_invalid;
19621 89 temp_zinit.counter[crSBOMBS] = padding;
19622 89 }
19623
19624 //Back to more OLD item code
19625
2/2
✓ Branch 0 taken 86 times.
✓ Branch 1 taken 12 times.
98 if(s_version < 10)
19626 {
19627
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12 if((Header->zelda_version > 0x192)||
19628 //new only
19629 ((Header->zelda_version == 0x192)&&(Header->build>173)))
19630 {
19631
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_getc(&temp,f))
19632 {
19633 return qe_invalid;
19634 }
19635
19636 12 addOldStyleFamily(&temp_zinit, itemsbuf, itype_wand, temp);
19637
19638
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_getc(&temp,f))
19639 {
19640 return qe_invalid;
19641 }
19642
19643 12 addOldStyleFamily(&temp_zinit, itemsbuf, itype_letter, temp);
19644
19645
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_getc(&temp,f))
19646 {
19647 return qe_invalid;
19648 }
19649
19650 12 addOldStyleFamily(&temp_zinit, itemsbuf, itype_lens, temp);
19651
19652
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_getc(&temp,f))
19653 {
19654 return qe_invalid;
19655 }
19656
19657 12 addOldStyleFamily(&temp_zinit, itemsbuf, itype_hookshot, temp);
19658
19659
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_getc(&temp,f))
19660 {
19661 return qe_invalid;
19662 }
19663
19664 12 addOldStyleFamily(&temp_zinit, itemsbuf, itype_bait, temp);
19665
19666
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_getc(&temp,f))
19667 {
19668 return qe_invalid;
19669 }
19670
19671 12 addOldStyleFamily(&temp_zinit, itemsbuf, itype_hammer, temp);
19672
19673
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_getc(&temp,f))
19674 {
19675 return qe_invalid;
19676 }
19677
19678 12 addOldStyleFamily(&temp_zinit, itemsbuf, itype_divinefire, temp);
19679
19680
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_getc(&temp,f))
19681 {
19682 return qe_invalid;
19683 }
19684
19685 12 addOldStyleFamily(&temp_zinit, itemsbuf, itype_divineescape, temp);
19686
19687
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_getc(&temp,f))
19688 {
19689 return qe_invalid;
19690 }
19691
19692 12 addOldStyleFamily(&temp_zinit, itemsbuf, itype_divineprotection, temp);
19693
19694
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_getc(&temp,f))
19695 {
19696 return qe_invalid;
19697 }
19698
19699
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(Header->zelda_version == 0x192)
19700 {
19701 for(int32_t q=0; q<32; q++)
19702 {
19703 if(!p_getc(&padding,f))
19704 {
19705 return qe_invalid;
19706 }
19707 }
19708 }
19709 12 }
19710 12 }
19711
19712 //old only
19713
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 98 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
98 if((Header->zelda_version == 0x192)&&(Header->build<174))
19714 {
19715 byte equipment, tmpitm; //bit flags
19716
19717 if(!p_getc(&equipment,f))
19718 {
19719 return qe_invalid;
19720 }
19721
19722 temp_zinit.set_item(iRaft, get_bit(&equipment, idE_RAFT)!=0);
19723 temp_zinit.set_item(iLadder, get_bit(&equipment, idE_LADDER)!=0);
19724 temp_zinit.set_item(iBook, get_bit(&equipment, idE_BOOK)!=0);
19725 temp_zinit.set_item(iMKey, get_bit(&equipment, idE_KEY)!=0);
19726 temp_zinit.set_item(iFlippers, get_bit(&equipment, idE_FLIPPERS)!=0);
19727 temp_zinit.set_item(iBoots, get_bit(&equipment, idE_BOOTS)!=0);
19728
19729
19730 if(!p_getc(&tmpitm,f))
19731 {
19732 return qe_invalid;
19733 }
19734
19735 temp_zinit.set_item(iWand, get_bit(&tmpitm, idI_WAND)!=0);
19736 temp_zinit.set_item(iLetter, get_bit(&tmpitm, idI_LETTER)!=0);
19737 temp_zinit.set_item(iLens, get_bit(&tmpitm, idI_LENS)!=0);
19738 temp_zinit.set_item(iHookshot, get_bit(&tmpitm, idI_HOOKSHOT)!=0);
19739 temp_zinit.set_item(iBait, get_bit(&tmpitm, idI_BAIT)!=0);
19740 temp_zinit.set_item(iHammer, get_bit(&tmpitm, idI_HAMMER)!=0);
19741 }
19742
19743
1/2
✓ Branch 0 taken 98 times.
✗ Branch 1 not taken.
98 if(!p_getc(&tempbyte,f))
19744 return qe_invalid;
19745 98 temp_zinit.mcounter[crLIFE] = tempbyte;
19746
19747
19748
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 86 times.
98 if(s_version < 14)
19749 {
19750 byte temphp;
19751
19752
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_getc(&temphp,f))
19753 {
19754 return qe_invalid;
19755 }
19756
19757 12 temp_zinit.counter[crLIFE]=temphp;
19758
19759
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_getc(&temphp,f))
19760 {
19761 return qe_invalid;
19762 }
19763
19764 12 temp_zinit.cont_heart=temphp;
19765 12 }
19766 else
19767 {
19768
1/2
✓ Branch 0 taken 86 times.
✗ Branch 1 not taken.
86 if(!p_igetw(&temp_zinit.counter[crLIFE],f))
19769 {
19770 return qe_invalid;
19771 }
19772
19773
1/2
✓ Branch 0 taken 86 times.
✗ Branch 1 not taken.
86 if(!p_igetw(&temp_zinit.cont_heart,f))
19774 {
19775 return qe_invalid;
19776 }
19777 }
19778
19779
1/2
✓ Branch 0 taken 98 times.
✗ Branch 1 not taken.
98 if(!p_getc(&temp_zinit.hcp,f))
19780 {
19781 return qe_invalid;
19782 }
19783
19784
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 86 times.
98 if(s_version >= 14)
19785 {
19786
1/2
✓ Branch 0 taken 86 times.
✗ Branch 1 not taken.
86 if(!p_getc(&temp_zinit.hcp_per_hc,f))
19787 {
19788 return qe_invalid;
19789 }
19790
19791
1/2
✓ Branch 0 taken 86 times.
✗ Branch 1 not taken.
86 if(s_version<16) // July 2007
19792 {
19793 if(get_qr(qr_BRANGPICKUP+1))
19794 temp_zinit.hcp_per_hc = 0xFF;
19795
19796 //Dispose of legacy rule
19797 set_qr(qr_BRANGPICKUP+1, 0);
19798 }
19799 86 }
19800
19801
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 89 times.
98 if(s_version < 29)
19802 {
19803
1/2
✓ Branch 0 taken 89 times.
✗ Branch 1 not taken.
89 if(!p_getc(&padding,f))
19804 return qe_invalid;
19805 89 temp_zinit.mcounter[crBOMBS] = padding;
19806 89 }
19807
19808
1/2
✓ Branch 0 taken 98 times.
✗ Branch 1 not taken.
98 if(!p_getc(&temp_zinit.counter[crKEYS],f))
19809 {
19810 return qe_invalid;
19811 }
19812
19813
1/2
✓ Branch 0 taken 98 times.
✗ Branch 1 not taken.
98 if(!p_igetw(&temp_zinit.counter[crMONEY],f))
19814 {
19815 return qe_invalid;
19816 }
19817
19818
1/2
✓ Branch 0 taken 98 times.
✗ Branch 1 not taken.
98 if(!p_getc(&tempbyte,f))
19819 return qe_invalid;
19820
2/2
✓ Branch 0 taken 784 times.
✓ Branch 1 taken 98 times.
882 for(int q = 0; q < 8; ++q)
19821 784 set_bit(temp_zinit.mcguffin, q+1, get_bitl(tempbyte, q));
19822
19823
3/6
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 86 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 12 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
98 if(s_version>12 || (Header->zelda_version == 0x211 && Header->build == 18))
19824 {
19825
2/2
✓ Branch 0 taken 5504 times.
✓ Branch 1 taken 86 times.
5590 for(int32_t i=0; i<64; i++)
19826 {
19827
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5504 times.
5504 if(!p_getc(&temp_zinit.map[i],f))
19828 {
19829 return qe_invalid;
19830 }
19831 5504 }
19832
19833
2/2
✓ Branch 0 taken 5504 times.
✓ Branch 1 taken 86 times.
5590 for(int32_t i=0; i<64; i++)
19834 {
19835
1/2
✓ Branch 0 taken 5504 times.
✗ Branch 1 not taken.
5504 if(!p_getc(&temp_zinit.compass[i],f))
19836 {
19837 return qe_invalid;
19838 }
19839 5504 }
19840 86 }
19841 else
19842 {
19843
2/2
✓ Branch 0 taken 384 times.
✓ Branch 1 taken 12 times.
396 for(int32_t i=0; i<32; i++)
19844 {
19845
1/2
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
384 if(!p_getc(&temp_zinit.map[i],f))
19846 {
19847 return qe_invalid;
19848 }
19849 384 }
19850
19851
2/2
✓ Branch 0 taken 384 times.
✓ Branch 1 taken 12 times.
396 for(int32_t i=0; i<32; i++)
19852 {
19853
1/2
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
384 if(!p_getc(&temp_zinit.compass[i],f))
19854 {
19855 return qe_invalid;
19856 }
19857 384 }
19858 }
19859
19860
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 98 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
98 if((Header->zelda_version > 0x192)||
19861 //new only
19862 ((Header->zelda_version == 0x192)&&(Header->build>173)))
19863 {
19864
3/6
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 86 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 12 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
98 if(s_version>12 || (Header->zelda_version == 0x211 && Header->build == 18))
19865 {
19866
2/2
✓ Branch 0 taken 5504 times.
✓ Branch 1 taken 86 times.
5590 for(int32_t i=0; i<64; i++)
19867 {
19868
1/2
✓ Branch 0 taken 5504 times.
✗ Branch 1 not taken.
5504 if(!p_getc(&temp_zinit.boss_key[i],f))
19869 {
19870 return qe_invalid;
19871 }
19872 5504 }
19873 86 }
19874 else
19875 {
19876
2/2
✓ Branch 0 taken 384 times.
✓ Branch 1 taken 12 times.
396 for(int32_t i=0; i<32; i++)
19877 {
19878
1/2
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
384 if(!p_getc(&temp_zinit.boss_key[i],f))
19879 {
19880 return qe_invalid;
19881 }
19882 384 }
19883 }
19884 98 }
19885
19886 byte tmpmisc[16];
19887
2/2
✓ Branch 0 taken 1568 times.
✓ Branch 1 taken 98 times.
1666 for(int32_t i=0; i<16; i++)
19888
1/2
✓ Branch 0 taken 1568 times.
✗ Branch 1 not taken.
1568 if(!p_getc(&tmpmisc[i],f))
19889 return qe_invalid;
19890 98 temp_zinit.flags.set(INIT_FL_CONTPERCENT,get_bit(tmpmisc,0));
19891 98 temp_zinit.magicdrainrate = get_bit(tmpmisc,1) ? 1 : 2; //Double Magic flag
19892 98 temp_zinit.flags.set(INIT_FL_CANSLASH,get_bit(tmpmisc,2));
19893
19894
4/4
✓ Branch 0 taken 86 times.
✓ Branch 1 taken 12 times.
✓ Branch 2 taken 48 times.
✓ Branch 3 taken 12 times.
146 if(s_version < 15) for(int32_t i=0; i<4; i++)
19895
1/2
✓ Branch 0 taken 48 times.
✗ Branch 1 not taken.
48 if(!p_getc(&sword_hearts[i],f))
19896 12 return qe_invalid;
19897
19898
1/2
✓ Branch 0 taken 98 times.
✗ Branch 1 not taken.
98 if(!p_getc(&temp_zinit.last_map,f))
19899 {
19900 return qe_invalid;
19901 }
19902
19903
1/2
✓ Branch 0 taken 98 times.
✗ Branch 1 not taken.
98 if(!p_getc(&temp_zinit.last_screen,f))
19904 {
19905 return qe_invalid;
19906 }
19907
19908
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 86 times.
98 if(s_version < 14)
19909 {
19910 byte tempmp;
19911
19912
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_getc(&tempmp,f))
19913 {
19914 return qe_invalid;
19915 }
19916
19917 12 temp_zinit.mcounter[crMAGIC]=tempmp;
19918
19919
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_getc(&tempmp,f))
19920 {
19921 return qe_invalid;
19922 }
19923
19924 12 temp_zinit.counter[crMAGIC]=tempmp;
19925 12 }
19926 else
19927 {
19928
1/2
✓ Branch 0 taken 86 times.
✗ Branch 1 not taken.
86 if(!p_igetw(&temp_zinit.mcounter[crMAGIC],f))
19929 {
19930 return qe_invalid;
19931 }
19932
19933
1/2
✓ Branch 0 taken 86 times.
✗ Branch 1 not taken.
86 if(!p_igetw(&temp_zinit.counter[crMAGIC],f))
19934 {
19935 return qe_invalid;
19936 }
19937 }
19938
19939
19940
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 86 times.
98 if(s_version < 15)
19941 {
19942
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(s_version < 12)
19943 {
19944 12 temp_zinit.mcounter[crMAGIC]*=32;
19945 12 temp_zinit.counter[crMAGIC]*=32;
19946 12 }
19947
19948
2/2
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 12 times.
60 for(int32_t i=0; i<4; i++)
19949 {
19950
1/2
✓ Branch 0 taken 48 times.
✗ Branch 1 not taken.
48 if(!p_getc(&beam_hearts[i],f))
19951 {
19952 return qe_invalid;
19953 }
19954 48 }
19955
19956
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_getc(&beam_percent,f))
19957 {
19958 return qe_invalid;
19959 }
19960 12 }
19961 else
19962 {
19963
1/2
✓ Branch 0 taken 86 times.
✗ Branch 1 not taken.
86 if(!p_getc(&temp_zinit.bomb_ratio,f))
19964 return qe_invalid;
19965
1/2
✓ Branch 0 taken 86 times.
✗ Branch 1 not taken.
86 if(temp_zinit.bomb_ratio < 1)
19966 temp_zinit.bomb_ratio = 1;
19967 86 else bomb_ratio = temp_zinit.bomb_ratio; //jank
19968 }
19969
19970
2/2
✓ Branch 0 taken 86 times.
✓ Branch 1 taken 12 times.
98 if(s_version < 15)
19971 {
19972 byte tempbp;
19973
19974
2/2
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 12 times.
60 for(int32_t i=0; i<4; i++)
19975 {
19976
2/4
✓ Branch 0 taken 48 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 48 times.
✗ Branch 3 not taken.
48 if(!(s_version < 14 ? p_getc(&tempbp,f) : p_igetw(&tempbp,f)))
19977 {
19978 return qe_invalid;
19979 }
19980
19981 48 beam_power[i]=tempbp;
19982 48 }
19983
19984
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_getc(&hookshot_links,f))
19985 {
19986 return qe_invalid;
19987 }
19988
19989
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(s_version>6)
19990 {
19991 if(!p_getc(&hookshot_length,f))
19992 {
19993 return qe_invalid;
19994 }
19995
19996 if(!p_getc(&longshot_links,f))
19997 {
19998 return qe_invalid;
19999 }
20000
20001 if(!p_getc(&longshot_length,f))
20002 {
20003 return qe_invalid;
20004 }
20005 }
20006 12 }
20007
20008
1/2
✓ Branch 0 taken 98 times.
✗ Branch 1 not taken.
98 if(!p_getc(&temp_zinit.msg_more_x,f))
20009 {
20010 return qe_invalid;
20011 }
20012
20013
1/2
✓ Branch 0 taken 98 times.
✗ Branch 1 not taken.
98 if(!p_getc(&temp_zinit.msg_more_y,f))
20014 {
20015 return qe_invalid;
20016 }
20017
20018
1/2
✓ Branch 0 taken 98 times.
✗ Branch 1 not taken.
98 if(!p_getc(&subscr_mode,f))
20019 return qe_invalid;
20020
20021 //old only
20022
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 98 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
98 if((Header->zelda_version == 0x192)&&(Header->build<174))
20023 {
20024 for(int32_t i=0; i<32; i++)
20025 {
20026 if(!p_getc(&temp_zinit.boss_key[i],f))
20027 {
20028 return qe_invalid;
20029 }
20030 }
20031 }
20032
20033
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 98 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
98 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>173))) //new only
20034 {
20035
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 86 times.
98 if(s_version <= 10)
20036 {
20037
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_getc(&tempbyte,f))
20038 {
20039 return qe_invalid;
20040 }
20041
20042 12 temp_zinit.start_dmap = (word)tempbyte;
20043 12 }
20044 else
20045 {
20046
1/2
✓ Branch 0 taken 86 times.
✗ Branch 1 not taken.
86 if(!p_igetw(&temp_zinit.start_dmap,f))
20047 {
20048 return qe_invalid;
20049 }
20050 }
20051
20052
1/2
✓ Branch 0 taken 98 times.
✗ Branch 1 not taken.
98 if(!p_getc(&temp_zinit.heroAnimationStyle,f))
20053 {
20054 return qe_invalid;
20055 }
20056 98 }
20057
20058
4/4
✓ Branch 0 taken 86 times.
✓ Branch 1 taken 12 times.
✓ Branch 2 taken 9 times.
✓ Branch 3 taken 77 times.
98 if(s_version>1 && s_version < 29)
20059 {
20060
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 if(!p_getc(&padding,f))
20061 return qe_invalid;
20062 77 temp_zinit.counter[crARROWS] = padding;
20063
20064
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 if(!p_getc(&padding,f))
20065 return qe_invalid;
20066 77 temp_zinit.mcounter[crARROWS] = padding;
20067 77 }
20068
20069
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 86 times.
98 if(s_version>2)
20070 {
20071
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 86 times.
86 if(s_version <= 10)
20072 {
20073 for(int32_t i=0; i<OLDMAXLEVELS; i++)
20074 {
20075 if(!p_getc(&(temp_zinit.level_keys[i]),f))
20076 {
20077 return qe_invalid;
20078 }
20079 }
20080 }
20081 else
20082 {
20083
2/2
✓ Branch 0 taken 44032 times.
✓ Branch 1 taken 86 times.
44118 for(int32_t i=0; i<MAXLEVELS; i++)
20084 {
20085
1/2
✓ Branch 0 taken 44032 times.
✗ Branch 1 not taken.
44032 if(!p_getc(&(temp_zinit.level_keys[i]),f))
20086 {
20087 return qe_invalid;
20088 }
20089 44032 }
20090 }
20091 86 }
20092
20093
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 86 times.
98 if(s_version>3)
20094 {
20095
1/2
✓ Branch 0 taken 86 times.
✗ Branch 1 not taken.
86 if(!p_igetw(&temp_zinit.ss_grid_x,f))
20096 {
20097 return qe_invalid;
20098 }
20099
20100
1/2
✓ Branch 0 taken 86 times.
✗ Branch 1 not taken.
86 if(!p_igetw(&temp_zinit.ss_grid_y,f))
20101 {
20102 return qe_invalid;
20103 }
20104
20105
1/2
✓ Branch 0 taken 86 times.
✗ Branch 1 not taken.
86 if(!p_igetw(&temp_zinit.ss_grid_xofs,f))
20106 {
20107 return qe_invalid;
20108 }
20109
20110
1/2
✓ Branch 0 taken 86 times.
✗ Branch 1 not taken.
86 if(!p_igetw(&temp_zinit.ss_grid_yofs,f))
20111 {
20112 return qe_invalid;
20113 }
20114
20115
1/2
✓ Branch 0 taken 86 times.
✗ Branch 1 not taken.
86 if(!p_igetw(&temp_zinit.ss_grid_color,f))
20116 {
20117 return qe_invalid;
20118 }
20119
20120
1/2
✓ Branch 0 taken 86 times.
✗ Branch 1 not taken.
86 if(!p_igetw(&temp_zinit.ss_bbox_1_color,f))
20121 {
20122 return qe_invalid;
20123 }
20124
20125
1/2
✓ Branch 0 taken 86 times.
✗ Branch 1 not taken.
86 if(!p_igetw(&temp_zinit.ss_bbox_2_color,f))
20126 {
20127 return qe_invalid;
20128 }
20129
20130
1/2
✓ Branch 0 taken 86 times.
✗ Branch 1 not taken.
86 if(!p_igetw(&temp_zinit.ss_flags,f))
20131 {
20132 return qe_invalid;
20133 }
20134
20135
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 86 times.
86 temp_zinit.ss_grid_x=zc_max(temp_zinit.ss_grid_x,1);
20136
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 86 times.
86 temp_zinit.ss_grid_y=zc_max(temp_zinit.ss_grid_y,1);
20137 86 }
20138
20139
3/4
✓ Branch 0 taken 86 times.
✓ Branch 1 taken 12 times.
✓ Branch 2 taken 86 times.
✗ Branch 3 not taken.
98 if(s_version>4 && s_version<15)
20140 {
20141 if(!p_getc(&moving_fairy_hearts,f))
20142 {
20143 return qe_invalid;
20144 }
20145
20146 if(!p_getc(&moving_fairy_heart_percent,f))
20147 {
20148 return qe_invalid;
20149 }
20150 }
20151
20152
3/4
✓ Branch 0 taken 86 times.
✓ Branch 1 taken 12 times.
✓ Branch 2 taken 86 times.
✗ Branch 3 not taken.
98 if(s_version>5 && s_version < 10)
20153 {
20154 if(!p_getc(&temp,f))
20155 {
20156 return qe_invalid;
20157 }
20158
20159 addOldStyleFamily(&temp_zinit, itemsbuf, itype_quiver, temp);
20160 }
20161
20162
3/4
✓ Branch 0 taken 86 times.
✓ Branch 1 taken 12 times.
✓ Branch 2 taken 86 times.
✗ Branch 3 not taken.
98 if(s_version>6 && s_version<15)
20163 {
20164 if(!p_getc(&stationary_fairy_hearts,f))
20165 {
20166 return qe_invalid;
20167 }
20168
20169 if(!p_getc(&stationary_fairy_heart_percent,f))
20170 {
20171 return qe_invalid;
20172 }
20173
20174 if(!p_getc(&moving_fairy_magic,f))
20175 {
20176 return qe_invalid;
20177 }
20178
20179 if(!p_getc(&moving_fairy_magic_percent,f))
20180 {
20181 return qe_invalid;
20182 }
20183
20184 if(!p_getc(&stationary_fairy_magic,f))
20185 {
20186 return qe_invalid;
20187 }
20188
20189 if(!p_getc(&stationary_fairy_magic_percent,f))
20190 {
20191 return qe_invalid;
20192 }
20193
20194 if(!p_getc(&blue_potion_hearts,f))
20195 {
20196 return qe_invalid;
20197 }
20198
20199 if(!p_getc(&blue_potion_heart_percent,f))
20200 {
20201 return qe_invalid;
20202 }
20203
20204 if(!p_getc(&red_potion_hearts,f))
20205 {
20206 return qe_invalid;
20207 }
20208
20209 if(!p_getc(&red_potion_heart_percent,f))
20210 {
20211 return qe_invalid;
20212 }
20213
20214 if(!p_getc(&blue_potion_magic,f))
20215 {
20216 return qe_invalid;
20217 }
20218
20219 if(!p_getc(&blue_potion_magic_percent,f))
20220 {
20221 return qe_invalid;
20222 }
20223
20224 if(!p_getc(&red_potion_magic,f))
20225 {
20226 return qe_invalid;
20227 }
20228
20229 if(!p_getc(&red_potion_magic_percent,f))
20230 {
20231 return qe_invalid;
20232 }
20233 }
20234
20235
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 86 times.
98 if(s_version>6)
20236
1/2
✓ Branch 0 taken 86 times.
✗ Branch 1 not taken.
86 if(!p_getc(&padding,f))
20237 return qe_invalid;
20238
20239
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 86 times.
98 if(s_version>7)
20240 {
20241
1/2
✓ Branch 0 taken 86 times.
✗ Branch 1 not taken.
86 if(!p_getc(&padding,f))
20242 {
20243 return qe_invalid;
20244 }
20245 86 }
20246
20247
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 86 times.
98 if(s_version>8)
20248 {
20249
1/2
✓ Branch 0 taken 86 times.
✗ Branch 1 not taken.
86 if(!p_igetw(&temp_zinit.mcounter[crMONEY],f))
20250 {
20251 return qe_invalid;
20252 }
20253
20254
1/2
✓ Branch 0 taken 86 times.
✗ Branch 1 not taken.
86 if(!p_igetw(&temp_zinit.mcounter[crKEYS],f))
20255 {
20256 return qe_invalid;
20257 }
20258 86 }
20259
20260
2/2
✓ Branch 0 taken 86 times.
✓ Branch 1 taken 12 times.
98 if(s_version>16)
20261 {
20262
1/2
✓ Branch 0 taken 86 times.
✗ Branch 1 not taken.
86 if(!p_getc(&tempbyte,f))
20263 {
20264 return qe_invalid;
20265 }
20266 86 temp_zinit.gravity = tempbyte*100;
20267
1/2
✓ Branch 0 taken 86 times.
✗ Branch 1 not taken.
86 if(!p_igetw(&temp_zinit.terminalv,f))
20268 {
20269 return qe_invalid;
20270 }
20271
20272
1/2
✓ Branch 0 taken 86 times.
✗ Branch 1 not taken.
86 if(!p_getc(&temp_zinit.msg_speed,f))
20273 {
20274 return qe_invalid;
20275 }
20276
20277
1/2
✓ Branch 0 taken 86 times.
✗ Branch 1 not taken.
86 if(!p_getc(&padding,f))
20278 {
20279 return qe_invalid;
20280 }
20281
20282
1/2
✓ Branch 0 taken 86 times.
✗ Branch 1 not taken.
86 if(!p_getc(&temp_zinit.jump_hero_layer_threshold,f))
20283 {
20284 return qe_invalid;
20285 }
20286 86 }
20287
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 else if (replay_version_check(0, 13))
20288 12 temp_zinit.msg_speed = 0;
20289
20290
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 86 times.
98 if(s_version>17)
20291 {
20292
1/2
✓ Branch 0 taken 86 times.
✗ Branch 1 not taken.
86 if(!p_getc(&temp_zinit.msg_more_is_offset,f))
20293 {
20294 return qe_invalid;
20295 }
20296 86 }
20297
20298 //expaned init data for larger values in 2.55
20299
2/2
✓ Branch 0 taken 89 times.
✓ Branch 1 taken 9 times.
98 if ( s_version >= 19 ) //expand init data bombs, sbombs, and arrows to 0xFFFF
20300 {
20301
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!p_igetw(&temp_zinit.counter[crBOMBS],f))
20302 {
20303 return qe_invalid;
20304 }
20305
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!p_igetw(&temp_zinit.counter[crSBOMBS],f))
20306 {
20307 return qe_invalid;
20308 }
20309
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!p_igetw(&temp_zinit.mcounter[crBOMBS],f))
20310 {
20311 return qe_invalid;
20312 }
20313
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!p_igetw(&temp_zinit.mcounter[crSBOMBS],f))
20314 {
20315 return qe_invalid;
20316 }
20317
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!p_igetw(&temp_zinit.counter[crARROWS],f))
20318 {
20319 return qe_invalid;
20320 }
20321
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!p_igetw(&temp_zinit.mcounter[crARROWS],f))
20322 {
20323 return qe_invalid;
20324 }
20325
20326 9 }
20327
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 89 times.
98 if ( s_version >= 20 )
20328 {
20329
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!p_igetw(&temp_zinit.heroStep,f))
20330 {
20331 return qe_invalid;
20332 }
20333 9 }
20334 else
20335 {
20336 89 temp_zinit.heroStep = 150; //1.5 pixels per frame
20337 }
20338
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 89 times.
98 if ( s_version >= 21 )
20339 {
20340
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!p_igetw(&temp_zinit.subscrSpeed,f))
20341 {
20342 return qe_invalid;
20343 }
20344 9 }
20345 else
20346 {
20347 89 temp_zinit.subscrSpeed = 1; //3 pixels per frame
20348 }
20349 //old only
20350
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 98 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
98 if((Header->zelda_version == 0x192)&&(Header->build<174))
20351 {
20352 byte items2;
20353
20354 if(!p_getc(&items2,f))
20355 {
20356 return qe_invalid;
20357 }
20358
20359 temp_zinit.set_item(iDivineFire, get_bit(&items2, idI_DFIRE)!=0);
20360 temp_zinit.set_item(iDivineEscape, get_bit(&items2, idI_FWIND)!=0);
20361 temp_zinit.set_item(iDivineProtection, get_bit(&items2, idI_NLOVE)!=0);
20362 }
20363
20364
1/2
✓ Branch 0 taken 98 times.
✗ Branch 1 not taken.
98 if(Header->zelda_version < 0x193)
20365 {
20366 for(int32_t q=0; q<96; q++)
20367 {
20368 if(!p_getc(&padding,f))
20369 {
20370 return qe_invalid;
20371 }
20372 }
20373
20374 //new only
20375 if((Header->zelda_version == 0x192)&&(Header->build>173))
20376 {
20377 if(!p_getc(&padding,f))
20378 {
20379 return qe_invalid;
20380 }
20381
20382 if(!p_getc(&padding,f))
20383 {
20384 return qe_invalid;
20385 }
20386 }
20387 }
20388 98 }
20389
20390
3/6
✓ Branch 0 taken 86 times.
✓ Branch 1 taken 16 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 86 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
102 if((Header->zelda_version < 0x211)||((Header->zelda_version == 0x211)&&(Header->build<15)))
20391 {
20392 //temp_zinit.shield=i_smallshield;
20393 16 int32_t sshieldid = getItemID(itemsbuf, itype_shield, i_smallshield);
20394
20395
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(sshieldid != -1)
20396 16 temp_zinit.set_item(sshieldid, true);
20397 16 }
20398
20399
3/6
✓ Branch 0 taken 98 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 98 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
102 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<27)))
20400 {
20401 4 temp_zinit.mcounter[crLIFE]=3;
20402 4 temp_zinit.counter[crLIFE]=3;
20403 4 temp_zinit.cont_heart=3;
20404 4 temp_zinit.mcounter[crBOMBS]=8;
20405 4 }
20406
20407
3/6
✓ Branch 0 taken 98 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 98 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
102 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<50)))
20408 {
20409 4 sword_hearts[0]=0;
20410 4 sword_hearts[1]=5;
20411 4 sword_hearts[2]=12;
20412 4 sword_hearts[3]=21;
20413 4 }
20414
20415
3/6
✓ Branch 0 taken 98 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 98 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
102 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<51)))
20416 {
20417 4 temp_zinit.last_map=0;
20418 4 temp_zinit.last_screen=0;
20419 4 }
20420
20421
3/6
✓ Branch 0 taken 98 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 98 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
102 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<68)))
20422 {
20423 4 temp_zinit.mcounter[crMAGIC]=0;
20424 4 temp_zinit.counter[crMAGIC]=0;
20425 4 temp_zinit.magicdrainrate = 2;
20426 4 }
20427
20428
3/6
✓ Branch 0 taken 98 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 98 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
102 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<129)))
20429 {
20430
20431
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 4 times.
20 for(int32_t x=0; x<4; x++)
20432 {
20433 16 beam_hearts[x]=100;
20434 16 }
20435
20436
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 4 times.
20 for(int32_t i=0; i<idBP_MAX; i++)
20437 {
20438 16 set_bit(&beam_percent,i,!get_qr(qr_LENSHINTS+i));
20439 16 set_qr(qr_LENSHINTS+i,0);
20440 16 }
20441
20442
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 4 times.
20 for(int32_t x=0; x<4; x++)
20443 {
20444 16 beam_power[x]=get_qr(qr_HIDECARRIEDITEMS)?50:100;
20445 16 }
20446
20447 4 set_qr(qr_HIDECARRIEDITEMS,0);
20448 4 hookshot_links=100;
20449 4 temp_zinit.msg_more_x=224;
20450 4 temp_zinit.msg_more_y=64;
20451 4 }
20452
20453 // Okay, let's put these legacy values into itemsbuf.
20454
2/2
✓ Branch 0 taken 86 times.
✓ Branch 1 taken 16 times.
102 if(s_version < 15)
20455
2/2
✓ Branch 0 taken 4096 times.
✓ Branch 1 taken 16 times.
4112 for(int32_t i=0; i<MAXITEMS; i++)
20456 {
20457
11/11
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 16 times.
✓ Branch 2 taken 16 times.
✓ Branch 3 taken 16 times.
✓ Branch 4 taken 16 times.
✓ Branch 5 taken 16 times.
✓ Branch 6 taken 16 times.
✓ Branch 7 taken 16 times.
✓ Branch 8 taken 3936 times.
✓ Branch 9 taken 16 times.
✓ Branch 10 taken 16 times.
4096 switch(i)
20458 {
20459 case iFairyStill:
20460 16 itemsbuf[i].misc1 = stationary_fairy_hearts;
20461 16 itemsbuf[i].misc2 = stationary_fairy_magic;
20462 16 itemsbuf[i].misc3 = 0;
20463 16 itemsbuf[i].flags |= stationary_fairy_heart_percent ? ITEM_FLAG1 : 0;
20464 16 itemsbuf[i].flags |= stationary_fairy_magic_percent ? ITEM_FLAG2 : 0;
20465 16 break;
20466
20467 case iFairyMoving:
20468 16 itemsbuf[i].misc1 = moving_fairy_hearts;
20469 16 itemsbuf[i].misc2 = moving_fairy_magic;
20470 16 itemsbuf[i].misc3 = 50;
20471 16 itemsbuf[i].flags |= moving_fairy_heart_percent ? ITEM_FLAG1 : 0;
20472 16 itemsbuf[i].flags |= moving_fairy_magic_percent ? ITEM_FLAG2 : 0;
20473 16 break;
20474
20475 case iRPotion:
20476 16 itemsbuf[i].misc1 = red_potion_hearts;
20477 16 itemsbuf[i].misc2 = red_potion_magic;
20478 16 itemsbuf[i].flags |= red_potion_heart_percent ? ITEM_FLAG1 : 0;
20479 16 itemsbuf[i].flags |= red_potion_magic_percent ? ITEM_FLAG2 : 0;
20480 16 break;
20481
20482 case iBPotion:
20483 16 itemsbuf[i].misc1 = blue_potion_hearts;
20484 16 itemsbuf[i].misc2 = blue_potion_magic;
20485 16 itemsbuf[i].flags |= blue_potion_heart_percent ? ITEM_FLAG1 : 0;
20486 16 itemsbuf[i].flags |= blue_potion_magic_percent ? ITEM_FLAG2 : 0;
20487 16 break;
20488
20489 case iSword:
20490 16 itemsbuf[i].pickup_hearts = sword_hearts[0];
20491 16 itemsbuf[i].misc1 = beam_hearts[0];
20492 16 itemsbuf[i].misc2 = beam_power[0];
20493 // It seems that ITEM_FLAG1 was already added by reset_itembuf()...
20494 16 itemsbuf[i].flags &= (!get_bit(&beam_percent,0)) ? ~ITEM_FLAG1 : ~0;
20495 16 break;
20496
20497 case iWSword:
20498 16 itemsbuf[i].pickup_hearts = sword_hearts[1];
20499 16 itemsbuf[i].misc1 = beam_hearts[1];
20500 16 itemsbuf[i].misc2 = beam_power[1];
20501 16 itemsbuf[i].flags &= (!get_bit(&beam_percent,1)) ? ~ITEM_FLAG1 : ~0;
20502 16 break;
20503
20504 case iMSword:
20505 16 itemsbuf[i].pickup_hearts = sword_hearts[2];
20506 16 itemsbuf[i].misc1 = beam_hearts[2];
20507 16 itemsbuf[i].misc2 = beam_power[2];
20508 16 itemsbuf[i].flags &= (!get_bit(&beam_percent,2)) ? ~ITEM_FLAG1 : ~0;
20509 16 break;
20510
20511 case iXSword:
20512 16 itemsbuf[i].pickup_hearts = sword_hearts[3];
20513 16 itemsbuf[i].misc1 = beam_hearts[3];
20514 16 itemsbuf[i].misc2 = beam_power[3];
20515 16 itemsbuf[i].flags &= (!get_bit(&beam_percent,3)) ? ~ITEM_FLAG1 : ~0;
20516 16 break;
20517
20518 case iHookshot:
20519 16 itemsbuf[i].misc1 = hookshot_length;
20520 16 itemsbuf[i].misc2 = hookshot_links;
20521 16 break;
20522
20523 case iLongshot:
20524 16 itemsbuf[i].misc1 = longshot_length;
20525 16 itemsbuf[i].misc2 = longshot_links;
20526 16 break;
20527 }
20528 4112 }
20529
20530
3/6
✓ Branch 0 taken 98 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 98 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
102 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<168)))
20531 {
20532 //was new subscreen rule
20533 4 subscr_mode=get_qr(qr_FREEFORM)?1:0;
20534 4 set_qr(qr_FREEFORM,0);
20535 4 }
20536
20537
3/6
✓ Branch 0 taken 98 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 98 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
102 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<185)))
20538 {
20539 4 temp_zinit.start_dmap=0;
20540 4 }
20541
20542
3/6
✓ Branch 0 taken 98 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 98 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
102 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<186)))
20543 {
20544 4 temp_zinit.heroAnimationStyle=get_qr(qr_BSZELDA)?1:0;
20545 4 }
20546
20547
3/4
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 86 times.
✓ Branch 2 taken 16 times.
✗ Branch 3 not taken.
102 if(s_version < 16 && get_bit(deprecated_rules, qr_COOLSCROLL+1))
20548 {
20549 //addOldStyleFamily(&temp_zinit, itemsbuf, itype_wallet, 4); //is this needed?
20550 temp_zinit.mcounter[crMONEY]=999;
20551 //temp_zinit.counter[crMONEY]=999; //This rule only gave you an invisible max wallet; it did not give you max rupies.
20552 }
20553
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 if(Header->zelda_version < 0x190) //1.84 bugfix. -Z
20554 {
20555 //temp_zinit.items[iBombBag] = true; //No, this is 30 max bombs!
20556 temp_zinit.mcounter[crBOMBS] = 8;
20557 }
20558 // al_trace("About to copy over new init data values for quest made in: %x\n", Header->zelda_version);
20559 //time to ensure that we port all new values properly:
20560
2/2
✓ Branch 0 taken 86 times.
✓ Branch 1 taken 16 times.
102 if(Header->zelda_version < 0x250)
20561 {
20562
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 temp_zinit.mcounter[crSBOMBS] = bomb_ratio > 0 ? ( temp_zinit.mcounter[crBOMBS]/temp_zinit.bomb_ratio ) : (temp_zinit.mcounter[crBOMBS]/4);
20563 16 }
20564
20565
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 93 times.
102 if(s_version > 21)
20566 {
20567
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!p_getc(&temp_zinit.hp_per_heart,f))
20568 {
20569 return qe_invalid;
20570 }
20571
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!p_getc(&temp_zinit.magic_per_block,f))
20572 {
20573 return qe_invalid;
20574 }
20575
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!p_getc(&temp_zinit.hero_damage_multiplier,f))
20576 {
20577 return qe_invalid;
20578 }
20579
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!p_getc(&temp_zinit.ene_damage_multiplier,f))
20580 {
20581 return qe_invalid;
20582 }
20583 9 }
20584 else
20585 {
20586 93 temp_zinit.hp_per_heart = 16; //HP_PER_HEART, previously hardcoded
20587 93 temp_zinit.magic_per_block = 32; //MAGICPERBLOCK, previously hardcoded
20588 93 temp_zinit.hero_damage_multiplier = 2; //DAMAGE_MULTIPLIER, previously hardcoded
20589 93 temp_zinit.ene_damage_multiplier = 4; //(HP_PER_HEART/4), previously hardcoded
20590 }
20591
20592
2/2
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 9 times.
102 if(s_version > 22)
20593 {
20594
2/2
✓ Branch 0 taken 225 times.
✓ Branch 1 taken 9 times.
234 for(int32_t q = crCUSTOM1; q <= crCUSTOM25; ++q)
20595
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 225 times.
225 if(!p_igetw(&temp_zinit.counter[q],f))
20596 return qe_invalid;
20597
2/2
✓ Branch 0 taken 225 times.
✓ Branch 1 taken 9 times.
234 for(int32_t q = crCUSTOM1; q <= crCUSTOM25; ++q)
20598
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 225 times.
225 if(!p_igetw(&temp_zinit.mcounter[q],f))
20599 return qe_invalid;
20600 9 }
20601
20602
20603
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 93 times.
102 if(s_version > 23)
20604 {
20605
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!p_getc(&temp_zinit.dither_type,f))
20606 {
20607 return qe_invalid;
20608 }
20609
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!p_getc(&temp_zinit.dither_arg,f))
20610 {
20611 return qe_invalid;
20612 }
20613
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!p_getc(&temp_zinit.dither_percent,f))
20614 {
20615 return qe_invalid;
20616 }
20617
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!p_getc(&temp_zinit.def_lightrad,f))
20618 {
20619 return qe_invalid;
20620 }
20621
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!p_getc(&temp_zinit.transdark_percent,f))
20622 {
20623 return qe_invalid;
20624 }
20625 9 }
20626 else
20627 {
20628 93 temp_zinit.dither_type = 0;
20629 93 temp_zinit.dither_arg = 0;
20630 93 temp_zinit.dither_percent = 20;
20631 93 temp_zinit.def_lightrad = 24;
20632 93 temp_zinit.transdark_percent = 0;
20633 }
20634
20635
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 93 times.
102 if(s_version > 24)
20636 {
20637
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!p_getc(&temp_zinit.darkcol,f))
20638 {
20639 return qe_invalid;
20640 }
20641 9 }
20642 else
20643 {
20644 93 temp_zinit.darkcol = BLACK;
20645 }
20646
20647
2/2
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 9 times.
102 if(s_version > 25)
20648 {
20649
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!p_igetl(&temp_zinit.gravity,f))
20650 {
20651 return qe_invalid;
20652 }
20653
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!p_igetl(&temp_zinit.swimgravity,f))
20654 {
20655 return qe_invalid;
20656 }
20657 9 }
20658
20659
20660
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 93 times.
102 if(s_version > 26)
20661 {
20662
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!p_igetw(&temp_zinit.heroSideswimUpStep,f))
20663 {
20664 return qe_invalid;
20665 }
20666
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!p_igetw(&temp_zinit.heroSideswimSideStep,f))
20667 {
20668 return qe_invalid;
20669 }
20670
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!p_igetw(&temp_zinit.heroSideswimDownStep,f))
20671 {
20672 return qe_invalid;
20673 }
20674 9 }
20675 else
20676 {
20677 93 temp_zinit.heroSideswimUpStep = 150;
20678 93 temp_zinit.heroSideswimSideStep = 100;
20679 93 temp_zinit.heroSideswimDownStep = 75;
20680 }
20681
20682
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 93 times.
102 if(s_version > 27)
20683 {
20684
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!p_igetl(&temp_zinit.exitWaterJump,f))
20685 {
20686 return qe_invalid;
20687 }
20688 9 }
20689 else
20690 {
20691 93 temp_zinit.exitWaterJump = 0;
20692 }
20693
20694
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 93 times.
102 if(s_version > 29)
20695 {
20696
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!p_igetl(&temp_zinit.bunny_ltm,f))
20697 {
20698 return qe_invalid;
20699 }
20700 9 }
20701 else
20702 {
20703 93 temp_zinit.bunny_ltm = 0;
20704 }
20705
20706
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 93 times.
102 if(s_version > 30)
20707 {
20708
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!p_getc(&temp_zinit.switchhookstyle,f))
20709 {
20710 return qe_invalid;
20711 }
20712 9 }
20713 else
20714 {
20715 93 temp_zinit.switchhookstyle = 1;
20716 }
20717
20718
2/2
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 9 times.
102 if(s_version > 31)
20719 {
20720
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!p_getc(&temp_zinit.magicdrainrate,f))
20721 {
20722 return qe_invalid;
20723 }
20724 9 }
20725
20726 102 temp_zinit.clear_genscript();
20727
2/2
✓ Branch 0 taken 95 times.
✓ Branch 1 taken 7 times.
102 if(s_version > 32)
20728 {
20729 7 word numgenscript = 0;
20730
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 if(!p_igetw(&numgenscript,f))
20731 return qe_invalid;
20732
2/4
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 7 times.
7 if (!(numgenscript >= 0 && numgenscript <= NUMSCRIPTSGENERIC))
20733 return qe_invalid;
20734
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
7 for(auto q = 1; q < numgenscript; ++q)
20735 {
20736 if(!p_getc(&tempbyte,f))
20737 return qe_invalid;
20738 if(!(tempbyte&2))
20739 continue;
20740 temp_zinit.gen_doscript.set(q, tempbyte&1);
20741 if(!p_igetw(&temp_zinit.gen_exitState[q],f))
20742 return qe_invalid;
20743 if(!p_igetw(&temp_zinit.gen_reloadState[q],f))
20744 return qe_invalid;
20745 for(auto p = 0; p < 8; ++p)
20746 if(!p_igetl(&temp_zinit.gen_initd[q][p],f))
20747 return qe_invalid;
20748 dword sz;
20749 if(!p_igetl(&sz,f))
20750 return qe_invalid;
20751 temp_zinit.gen_data[q].resize(sz);
20752 std::vector<int32_t> dummy;
20753 if(!p_getlvec(&dummy,f))
20754 return qe_invalid;
20755 temp_zinit.gen_data[q] = dummy;
20756 if(!p_igetl(&temp_zinit.gen_eventstate[q],f))
20757 return qe_invalid;
20758 }
20759 7 }
20760
2/2
✓ Branch 0 taken 98 times.
✓ Branch 1 taken 4 times.
102 if(s_version > 33)
20761 {
20762
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&temp_zinit.hero_swim_mult,f))
20763 return qe_invalid;
20764
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&temp_zinit.hero_swim_div,f))
20765 return qe_invalid;
20766 4 }
20767
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 if(s_version > 34)
20768 {
20769 uint32_t num_used_mapscr_data;
20770 if(!p_igetl(&num_used_mapscr_data,f))
20771 return qe_invalid;
20772 for(uint32_t q = 0; q < num_used_mapscr_data; ++q)
20773 {
20774 uint32_t sz;
20775 if(!p_igetl(&sz,f))
20776 return qe_invalid;
20777 temp_zinit.screen_data[q].resize(sz);
20778 if(sz)
20779 {
20780 std::vector<int32_t> dummy;
20781 if(!p_getlvec(&dummy,f))
20782 return qe_invalid;
20783 temp_zinit.screen_data[q] = dummy;
20784 }
20785 }
20786 }
20787
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 if (s_version > 35)
20788 if(!p_igetzf(&temp_zinit.shove_offset,f))
20789 return qe_invalid;
20790
20791 102 temp_zinit.counter[crLIFE] *= temp_zinit.hp_per_heart;
20792 102 temp_zinit.mcounter[crLIFE] *= temp_zinit.hp_per_heart;
20793
2/2
✓ Branch 0 taken 39 times.
✓ Branch 1 taken 63 times.
102 if(!temp_zinit.flags.get(INIT_FL_CONTPERCENT))
20794 63 temp_zinit.cont_heart *= temp_zinit.hp_per_heart;
20795
20796 102 return 0;
20797 102 }
20798 131 int32_t readinitdata(PACKFILE *f, zquestheader *Header)
20799 {
20800 131 zinitdata temp_zinit = {};
20801
20802
3/4
✓ Branch 0 taken 127 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
131 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_initdata);
20803
20804 int32_t dummy;
20805 131 word s_version=0, s_cversion=0;
20806 byte padding;
20807
20808
2/2
✓ Branch 0 taken 127 times.
✓ Branch 1 taken 4 times.
131 if(Header->zelda_version > 0x192)
20809 {
20810
2/4
✓ Branch 0 taken 127 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 127 times.
✗ Branch 3 not taken.
127 if(!p_igetw(&s_version,f))
20811 return qe_invalid;
20812 127 FFCore.quest_format[vInitData] = s_version;
20813
20814
2/4
✓ Branch 0 taken 127 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 127 times.
✗ Branch 3 not taken.
127 if(!p_igetw(&s_cversion,f))
20815 return qe_invalid;
20816
20817 //section size
20818
2/4
✓ Branch 0 taken 127 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 127 times.
✗ Branch 3 not taken.
127 if(!p_igetl(&dummy,f))
20819 return qe_invalid;
20820 127 }
20821
20822
2/2
✓ Branch 0 taken 102 times.
✓ Branch 1 taken 29 times.
131 if(s_version < 37)
20823 {
20824
2/4
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 102 times.
102 if(auto ret = readinitdata_old(f,Header,s_version,s_cversion,temp_zinit))
20825 return ret;
20826 102 }
20827 else
20828 {
20829 29 subscr_mode = ssdtMAX;
20830
2/2
✓ Branch 0 taken 928 times.
✓ Branch 1 taken 29 times.
957 for(int q = 0; q < MAXITEMS/8; ++q)
20831
2/4
✓ Branch 0 taken 928 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 928 times.
928 if(!p_getc(&temp_zinit.items[q], f))
20832 return qe_invalid;
20833
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 1856 times.
1885 for(int q = 0; q < MAXLEVELS/8; ++q)
20834 {
20835
2/4
✓ Branch 0 taken 1856 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1856 times.
✗ Branch 3 not taken.
1856 if(!p_getc(&temp_zinit.map[q], f))
20836 return qe_invalid;
20837
2/4
✓ Branch 0 taken 1856 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1856 times.
1856 if(!p_getc(&temp_zinit.compass[q], f))
20838 return qe_invalid;
20839
2/4
✓ Branch 0 taken 1856 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1856 times.
1856 if(!p_getc(&temp_zinit.boss_key[q], f))
20840 return qe_invalid;
20841
2/4
✓ Branch 0 taken 1856 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1856 times.
✗ Branch 3 not taken.
1856 if(!p_getc(&temp_zinit.mcguffin[q], f))
20842 return qe_invalid;
20843 1856 }
20844
2/4
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
29 if(!p_getbvec(&temp_zinit.level_keys, f))
20845 return qe_invalid;
20846 byte num_counters;
20847
2/4
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
29 if(!p_getc(&num_counters,f))
20848 return qe_invalid;
20849
2/2
✓ Branch 0 taken 3103 times.
✓ Branch 1 taken 29 times.
3132 for(int q = 0; q < num_counters; ++q)
20850
2/4
✓ Branch 0 taken 3103 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 3103 times.
3103 if(!p_igetw(&temp_zinit.counter[q],f))
20851 return qe_invalid;
20852
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 3103 times.
3132 for(int q = 0; q < num_counters; ++q)
20853
2/4
✓ Branch 0 taken 3103 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 3103 times.
3103 if(!p_igetw(&temp_zinit.mcounter[q],f))
20854 return qe_invalid;
20855
2/4
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
29 if(!p_getc(&temp_zinit.bomb_ratio,f))
20856 return qe_invalid;
20857
2/4
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
29 if(!p_getc(&temp_zinit.hcp,f))
20858 return qe_invalid;
20859
2/4
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
29 if(!p_getc(&temp_zinit.hcp_per_hc,f))
20860 return qe_invalid;
20861
2/4
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
29 if(!p_igetw(&temp_zinit.cont_heart,f))
20862 return qe_invalid;
20863
2/4
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
29 if(!p_getc(&temp_zinit.hp_per_heart,f))
20864 return qe_invalid;
20865
2/4
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
29 if(!p_getc(&temp_zinit.magic_per_block,f))
20866 return qe_invalid;
20867
2/4
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
29 if(!p_getc(&temp_zinit.hero_damage_multiplier,f))
20868 return qe_invalid;
20869
2/4
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
29 if(!p_getc(&temp_zinit.ene_damage_multiplier,f))
20870 return qe_invalid;
20871
2/4
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
29 if(!p_getc(&temp_zinit.dither_type,f))
20872 return qe_invalid;
20873
2/4
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
29 if(!p_getc(&temp_zinit.dither_arg,f))
20874 return qe_invalid;
20875
2/4
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
29 if(!p_getc(&temp_zinit.dither_percent,f))
20876 return qe_invalid;
20877
2/4
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
29 if(!p_getc(&temp_zinit.def_lightrad,f))
20878 return qe_invalid;
20879
2/4
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
29 if(!p_getc(&temp_zinit.transdark_percent,f))
20880 return qe_invalid;
20881
2/4
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
29 if(!p_getc(&temp_zinit.darkcol,f))
20882 return qe_invalid;
20883
2/4
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
29 if(!p_igetl(&temp_zinit.ss_grid_x,f))
20884 return qe_invalid;
20885
2/4
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
29 if(!p_igetl(&temp_zinit.ss_grid_y,f))
20886 return qe_invalid;
20887
2/4
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
29 if(!p_igetl(&temp_zinit.ss_grid_xofs,f))
20888 return qe_invalid;
20889
2/4
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
29 if(!p_igetl(&temp_zinit.ss_grid_yofs,f))
20890 return qe_invalid;
20891
2/4
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
29 if(!p_igetl(&temp_zinit.ss_grid_color,f))
20892 return qe_invalid;
20893
2/4
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
29 if(!p_igetl(&temp_zinit.ss_bbox_1_color,f))
20894 return qe_invalid;
20895
2/4
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
29 if(!p_igetl(&temp_zinit.ss_bbox_2_color,f))
20896 return qe_invalid;
20897
2/4
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
29 if(!p_igetl(&temp_zinit.ss_flags,f))
20898 return qe_invalid;
20899
2/4
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
29 if(!p_getbitstr(&temp_zinit.flags,f))
20900 return qe_invalid;
20901
2/4
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
29 if(!p_getc(&temp_zinit.last_map,f))
20902 return qe_invalid;
20903
2/4
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
29 if(!p_getc(&temp_zinit.last_screen,f))
20904 return qe_invalid;
20905
2/4
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
29 if(!p_getc(&temp_zinit.msg_more_x,f))
20906 return qe_invalid;
20907
2/4
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
29 if(!p_getc(&temp_zinit.msg_more_y,f))
20908 return qe_invalid;
20909
2/4
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
29 if(!p_getc(&temp_zinit.msg_more_is_offset,f))
20910 return qe_invalid;
20911
2/4
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
29 if(!p_getc(&temp_zinit.msg_speed,f))
20912 return qe_invalid;
20913
2/4
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
29 if(!p_igetl(&temp_zinit.gravity,f))
20914 return qe_invalid;
20915
2/4
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
29 if(!p_igetl(&temp_zinit.swimgravity,f))
20916 return qe_invalid;
20917
2/4
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
29 if(!p_igetw(&temp_zinit.terminalv,f))
20918 return qe_invalid;
20919
2/4
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
29 if(!p_getc(&temp_zinit.hero_swim_speed,f))
20920 return qe_invalid;
20921
2/4
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
29 if(!p_getc(&temp_zinit.hero_swim_mult,f))
20922 return qe_invalid;
20923
2/4
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
29 if(!p_getc(&temp_zinit.hero_swim_div,f))
20924 return qe_invalid;
20925
2/4
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
29 if(!p_igetw(&temp_zinit.heroSideswimUpStep,f))
20926 return qe_invalid;
20927
2/4
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
29 if(!p_igetw(&temp_zinit.heroSideswimSideStep,f))
20928 return qe_invalid;
20929
2/4
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
29 if(!p_igetw(&temp_zinit.heroSideswimDownStep,f))
20930 return qe_invalid;
20931
2/4
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
29 if(!p_igetl(&temp_zinit.exitWaterJump,f))
20932 return qe_invalid;
20933
2/4
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
29 if(!p_igetw(&temp_zinit.heroStep,f))
20934 return qe_invalid;
20935
2/4
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
29 if(!p_getc(&temp_zinit.heroAnimationStyle,f))
20936 return qe_invalid;
20937
2/4
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
29 if(!p_getc(&temp_zinit.jump_hero_layer_threshold,f))
20938 return qe_invalid;
20939
2/4
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
29 if(!p_igetl(&temp_zinit.bunny_ltm,f))
20940 return qe_invalid;
20941
2/4
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
29 if(!p_igetw(&temp_zinit.start_dmap,f))
20942 return qe_invalid;
20943
2/4
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
29 if(!p_igetw(&temp_zinit.subscrSpeed,f))
20944 return qe_invalid;
20945
2/4
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
29 if(!p_getc(&temp_zinit.switchhookstyle,f))
20946 return qe_invalid;
20947
2/4
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
29 if(!p_getc(&temp_zinit.magicdrainrate,f))
20948 return qe_invalid;
20949
2/4
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
29 if(!p_igetzf(&temp_zinit.shove_offset,f))
20950 return qe_invalid;
20951
2/4
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
29 if(!p_getbitstr(&temp_zinit.gen_doscript, f))
20952 return qe_invalid;
20953
2/4
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
29 if(!p_getbmap(&temp_zinit.gen_exitState, f))
20954 return qe_invalid;
20955
2/4
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
29 if(!p_getbmap(&temp_zinit.gen_reloadState, f))
20956 return qe_invalid;
20957
2/4
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
29 if(!p_getbmap(&temp_zinit.gen_initd, f))
20958 return qe_invalid;
20959
2/4
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
29 if(!p_getbmap(&temp_zinit.gen_eventstate, f))
20960 return qe_invalid;
20961
2/4
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
29 if(!p_getbmap(&temp_zinit.gen_data, f))
20962 return qe_invalid;
20963
2/4
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
29 if(!p_getbmap(&temp_zinit.screen_data, f))
20964 return qe_invalid;
20965
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 21 times.
29 if (s_version >= 38)
20966 {
20967
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 if (!p_getc(&temp_zinit.spriteflickerspeed, f))
20968 return qe_invalid;
20969
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 if (!p_getc(&temp_zinit.spriteflickercolor, f))
20970 return qe_invalid;
20971
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 if (!p_getc(&temp_zinit.spriteflickertransp, f))
20972 return qe_invalid;
20973 8 }
20974 }
20975
1/2
✓ Branch 0 taken 131 times.
✗ Branch 1 not taken.
131 if (should_skip)
20976 return 0;
20977
20978
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 131 times.
131 if(loading_tileset_flags & TILESET_CLEARMAPS)
20979 {
20980 temp_zinit.last_map = 0;
20981 temp_zinit.last_screen = 0;
20982 temp_zinit.screen_data.clear();
20983 }
20984
1/2
✓ Branch 0 taken 131 times.
✗ Branch 1 not taken.
131 temp_zinit.normalize();
20985
1/2
✓ Branch 0 taken 131 times.
✗ Branch 1 not taken.
131 zinit = temp_zinit;
20986
20987
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 131 times.
131 if(zinit.heroAnimationStyle==las_zelda3slow)
20988 {
20989 hero_animation_speed=2;
20990 }
20991 else
20992 {
20993 131 hero_animation_speed=1;
20994 }
20995
20996 131 return 0;
20997 131 }
20998
20999 /*
21000 void setupitemdropsets()
21001 {
21002 for(int32_t i=0; i<isMAX; i++)
21003 {
21004 memcpy(&item_drop_sets[i], &default_item_drop_sets[i], sizeof(item_drop_object));
21005 }
21006 }
21007 */
21008
21009 119 int32_t readitemdropsets(PACKFILE *f, int32_t version, word build)
21010 {
21011
2/2
✓ Branch 0 taken 115 times.
✓ Branch 1 taken 4 times.
119 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_itemdropsets);
21012
21013 119 build=build; // here to prevent compiler warnings
21014 dword dummy_dword;
21015 119 word item_drop_sets_to_read=0;
21016 item_drop_object tempitemdrop;
21017 119 word s_version=0, s_cversion=0;
21018
21019
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 119 times.
119 if (!should_skip)
21020
2/2
✓ Branch 0 taken 30464 times.
✓ Branch 1 taken 119 times.
30583 for(int32_t i=0; i<MAXITEMDROPSETS; i++)
21021 {
21022 30464 memset(&item_drop_sets[i], 0, sizeof(item_drop_object));
21023 30583 }
21024
21025
2/2
✓ Branch 0 taken 115 times.
✓ Branch 1 taken 4 times.
119 if(version > 0x192)
21026 {
21027 115 item_drop_sets_to_read=0;
21028
21029 //section version info
21030
1/2
✓ Branch 0 taken 115 times.
✗ Branch 1 not taken.
115 if(!p_igetw(&s_version,f))
21031 {
21032 return qe_invalid;
21033 }
21034
21035 115 FFCore.quest_format[vItemDropsets] = s_version;
21036
21037 //al_trace("Item drop sets version %d\n", s_version);
21038
1/2
✓ Branch 0 taken 115 times.
✗ Branch 1 not taken.
115 if(!p_igetw(&s_cversion,f))
21039 {
21040 return qe_invalid;
21041 }
21042
21043 //section size
21044
1/2
✓ Branch 0 taken 115 times.
✗ Branch 1 not taken.
115 if(!p_igetl(&dummy_dword,f))
21045 {
21046 return qe_invalid;
21047 }
21048
21049 //finally... section data
21050
1/2
✓ Branch 0 taken 115 times.
✗ Branch 1 not taken.
115 if(!p_igetw(&item_drop_sets_to_read,f))
21051 {
21052 return qe_invalid;
21053 }
21054
21055
2/4
✓ Branch 0 taken 115 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 115 times.
✗ Branch 3 not taken.
115 if (!(item_drop_sets_to_read >= 0 && item_drop_sets_to_read <= MAXITEMDROPSETS))
21056 {
21057 return qe_invalid;
21058 }
21059 115 }
21060 else
21061 {
21062 4 init_item_drop_sets();
21063 }
21064
21065
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 115 times.
119 if(s_version>=1)
21066 {
21067
2/2
✓ Branch 0 taken 2095 times.
✓ Branch 1 taken 115 times.
2210 for(int32_t i=0; i<item_drop_sets_to_read; i++)
21068 {
21069
1/2
✓ Branch 0 taken 2095 times.
✗ Branch 1 not taken.
2095 if(!p_getstr(tempitemdrop.name,sizeof(tempitemdrop.name)-1,f))
21070 {
21071 return qe_invalid;
21072 }
21073
21074
2/2
✓ Branch 0 taken 20950 times.
✓ Branch 1 taken 2095 times.
23045 for(int32_t j=0; j<10; ++j)
21075 {
21076
1/2
✓ Branch 0 taken 20950 times.
✗ Branch 1 not taken.
20950 if(!p_igetw(&tempitemdrop.item[j],f))
21077 {
21078 return qe_invalid;
21079 }
21080 20950 }
21081
21082
2/2
✓ Branch 0 taken 23045 times.
✓ Branch 1 taken 2095 times.
25140 for(int32_t j=0; j<11; ++j)
21083 {
21084
1/2
✓ Branch 0 taken 23045 times.
✗ Branch 1 not taken.
23045 if(!p_igetw(&tempitemdrop.chance[j],f))
21085 {
21086 return qe_invalid;
21087 }
21088 23045 }
21089
21090 // Dec 2008: Addition of the 'Tall Grass' set, #12,
21091 // overrides the quest's set #12.
21092
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2095 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2095 if(s_version<2 && i==12)
21093 continue;
21094
21095 // Deprecated: qr_NOCLOCKS and qr_ALLOW10RUPEEDROPS
21096
1/4
✓ Branch 0 taken 2095 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2095 if(s_version<2) for(int32_t j=0; j<10; ++j)
21097 {
21098 int32_t it = tempitemdrop.item[j];
21099
21100 if((itemsbuf[it].family == itype_rupee
21101 && ((itemsbuf[it].amount)&0xFFF) == 10)
21102 && !get_bit(deprecated_rules, qr_ALLOW10RUPEEDROPS_DEP))
21103 {
21104 tempitemdrop.chance[j+1]=0;
21105 }
21106 else if(itemsbuf[it].family == itype_clock && get_bit(deprecated_rules, qr_NOCLOCKS_DEP))
21107 {
21108 tempitemdrop.chance[j+1]=0;
21109 }
21110
21111 // From Sept 2007 to Dec 2008, non-gameplay items were prohibited.
21112 if(itemsbuf[it].family == itype_misc)
21113 {
21114 // If a non-gameplay item was selected, then item drop was aborted.
21115 // Reflect this by increasing the 'Nothing' chance accordingly.
21116 tempitemdrop.chance[0]+=tempitemdrop.chance[j+1];
21117 tempitemdrop.chance[j+1]=0;
21118 }
21119 }
21120
21121
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2095 times.
2095 if (!should_skip)
21122 2095 memcpy(&item_drop_sets[i], &tempitemdrop, sizeof(item_drop_object));
21123 2095 }
21124 115 }
21125
21126 119 return 0;
21127 119 }
21128
21129 115 int32_t readfavorites(PACKFILE *f, int32_t, word)
21130 {
21131
1/2
✓ Branch 0 taken 115 times.
✗ Branch 1 not taken.
115 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_favorites);
21132
21133 int32_t temp_num;
21134 dword dummy_dword;
21135 word num_favorite_combos;
21136 word num_favorite_combo_aliases;
21137 115 word s_version=0, s_cversion=0;
21138
21139 //section version info
21140
1/2
✓ Branch 0 taken 115 times.
✗ Branch 1 not taken.
115 if(!p_igetw(&s_version,f))
21141 {
21142 return qe_invalid;
21143 }
21144
21145
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 115 times.
115 if (!should_skip)
21146 115 FFCore.quest_format[vFavourites] = s_version;
21147
21148
1/2
✓ Branch 0 taken 115 times.
✗ Branch 1 not taken.
115 if(!p_igetw(&s_cversion,f))
21149 {
21150 return qe_invalid;
21151 }
21152
21153 //section size
21154
1/2
✓ Branch 0 taken 115 times.
✗ Branch 1 not taken.
115 if(!p_igetl(&dummy_dword,f))
21155 {
21156 return qe_invalid;
21157 }
21158
21159 115 word per_row = FAVORITECOMBO_PER_ROW;
21160 115 word per_page = FAVORITECOMBO_PER_PAGE;
21161
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 33 times.
115 if(s_version >= 3)
21162
1/2
✓ Branch 0 taken 33 times.
✗ Branch 1 not taken.
33 if(!p_igetw(&per_row,f))
21163 return qe_invalid;
21164
2/2
✓ Branch 0 taken 86 times.
✓ Branch 1 taken 29 times.
115 if(s_version >= 4)
21165
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29 if(!p_igetw(&per_page,f))
21166 return qe_invalid;
21167 //finally... section data
21168
1/2
✓ Branch 0 taken 115 times.
✗ Branch 1 not taken.
115 if(!p_igetw(&num_favorite_combos,f))
21169 {
21170 return qe_invalid;
21171 }
21172
21173 //Hack; port old favorite combos
21174
3/4
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 33 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 82 times.
115 if(s_version < 3 && num_favorite_combos == 100)
21175 82 per_row = 13;
21176
21177
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 115 times.
115 if (!should_skip)
21178
2/2
✓ Branch 0 taken 144900 times.
✓ Branch 1 taken 115 times.
145015 for(int q = 0; q < MAXFAVORITECOMBOS; ++q)
21179 145015 favorite_combos[q] = -1;
21180 115 byte favtype = 0;
21181
2/2
✓ Branch 0 taken 9369 times.
✓ Branch 1 taken 115 times.
9484 for(int32_t i=0; i<num_favorite_combos; i++)
21182 {
21183
2/2
✓ Branch 0 taken 1165 times.
✓ Branch 1 taken 8204 times.
9369 if (s_version >= 4)
21184 {
21185
1/2
✓ Branch 0 taken 1165 times.
✗ Branch 1 not taken.
1165 if (!p_getc(&favtype, f))
21186 {
21187 return qe_invalid;
21188 }
21189 1165 }
21190 else
21191 8204 favtype = 0;
21192
1/2
✓ Branch 0 taken 9369 times.
✗ Branch 1 not taken.
9369 if(!p_igetl(&temp_num,f))
21193 {
21194 return qe_invalid;
21195 }
21196
21197
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9369 times.
9369 if (should_skip)
21198 continue;
21199
21200
2/2
✓ Branch 0 taken 1165 times.
✓ Branch 1 taken 8204 times.
9369 if(per_row == FAVORITECOMBO_PER_ROW)
21201 {
21202 1165 favorite_combos[i] = temp_num;
21203 1165 favorite_combo_modes[i] = favtype;
21204 1165 }
21205 else
21206 {
21207 8204 int new_i = (i%per_row) + (i/per_row)*FAVORITECOMBO_PER_ROW;
21208 8204 favorite_combos[new_i]=temp_num;
21209 8204 favorite_combo_modes[new_i] = favtype;
21210 }
21211 9369 }
21212
21213 // Discard the separate favorite aliases list from previous versions
21214
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 86 times.
115 if(s_version<4)
21215 {
21216
1/2
✓ Branch 0 taken 86 times.
✗ Branch 1 not taken.
86 if (!p_igetw(&num_favorite_combo_aliases, f))
21217 {
21218 return qe_invalid;
21219 }
21220
21221
2/2
✓ Branch 0 taken 8200 times.
✓ Branch 1 taken 86 times.
8286 for (int32_t i = 0; i < num_favorite_combo_aliases; i++)
21222 {
21223
1/2
✓ Branch 0 taken 8200 times.
✗ Branch 1 not taken.
8200 if (!p_igetl(&temp_num, f))
21224 {
21225 return qe_invalid;
21226 }
21227 8200 }
21228 86 }
21229
21230 115 word max_combo_cols = 0;
21231 115 word max_mappages = 0;
21232
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 33 times.
115 if(s_version >= 2)
21233 {
21234
1/2
✓ Branch 0 taken 33 times.
✗ Branch 1 not taken.
33 if(!p_igetw(&max_combo_cols,f))
21235 return qe_invalid;
21236 33 int32_t tmp = 0, tmp2 = 0, tmp3 = 0;
21237
2/2
✓ Branch 0 taken 132 times.
✓ Branch 1 taken 33 times.
165 for(int q = 0; q < max_combo_cols; ++q)
21238 {
21239
1/2
✓ Branch 0 taken 132 times.
✗ Branch 1 not taken.
132 if(!p_igetl(&tmp,f))
21240 return qe_invalid;
21241
1/2
✓ Branch 0 taken 132 times.
✗ Branch 1 not taken.
132 if(!p_igetl(&tmp2,f))
21242 return qe_invalid;
21243
1/2
✓ Branch 0 taken 132 times.
✗ Branch 1 not taken.
132 if(!p_igetl(&tmp3,f))
21244 return qe_invalid;
21245
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 132 times.
132 if(q < MAX_COMBO_COLS)
21246 {
21247 132 First[q] = tmp;
21248 132 combo_alistpos[q] = tmp2;
21249 132 combo_pool_listpos[q] = tmp3;
21250 132 }
21251 132 }
21252
21253
1/2
✓ Branch 0 taken 33 times.
✗ Branch 1 not taken.
33 if(!p_igetw(&max_mappages,f))
21254 return qe_invalid;
21255
2/2
✓ Branch 0 taken 297 times.
✓ Branch 1 taken 33 times.
330 for(int q = 0; q < max_mappages; ++q)
21256 {
21257
1/2
✓ Branch 0 taken 297 times.
✗ Branch 1 not taken.
297 if(!p_igetl(&tmp,f))
21258 return qe_invalid;
21259
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 297 times.
297 if(!p_igetl(&tmp2,f))
21260 return qe_invalid;
21261
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 297 times.
297 if(q < MAX_MAPPAGE_BTNS)
21262 {
21263 297 map_page[q].map = tmp;
21264 297 map_page[q].screen = tmp2;
21265 297 }
21266 297 }
21267 33 }
21268
21269
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 115 times.
115 if (should_skip)
21270 return 0;
21271
21272
2/2
✓ Branch 0 taken 328 times.
✓ Branch 1 taken 115 times.
443 for(int q = max_combo_cols; q < MAX_COMBO_COLS; ++q)
21273 {
21274 328 First[q] = 0;
21275 328 combo_alistpos[q] = 0;
21276 328 combo_pool_listpos[q] = 0;
21277 328 }
21278
2/2
✓ Branch 0 taken 738 times.
✓ Branch 1 taken 115 times.
853 for(int q = max_mappages; q < MAX_MAPPAGE_BTNS; ++q)
21279 {
21280 738 map_page[q].map = 0;
21281 738 map_page[q].screen = 0;
21282 738 }
21283
21284 115 return 0;
21285 115 }
21286
21287 /*
21288 switch (ret) {
21289 case 0:
21290 break;
21291
21292 case qe_invalid:
21293 goto invalid;
21294 break;
21295 default:
21296 pack_fclose(f);
21297 if(!oldquest)
21298 delete_file(tmpfilename);
21299 return ret;
21300 break;
21301 }
21302 */
21303
21304 const char *skip_text[skip_max]=
21305 {
21306 "skip_header", "skip_rules", "skip_strings", "skip_misc",
21307 "skip_tiles", "skip_combos", "skip_comboaliases", "skip_csets",
21308 "skip_maps", "skip_dmaps", "skip_doors", "skip_items",
21309 "skip_weapons", "skip_colors", "skip_icons", "skip_initdata",
21310 "skip_guys", "skip_herosprites", "skip_subscreens", "skip_ffscript",
21311 "skip_sfx", "skip_midis", "skip_cheats", "skip_itemdropsets",
21312 "skip_favorites"
21313 };
21314
21315
21316 void port250QuestRules(){
21317
21318 portCandleRules(); //Candle
21319 portBombRules();
21320
21321 }
21322
21323 void portCandleRules()
21324 {
21325 bool hurtshero = get_qr(qr_FIREPROOFHERO);
21326 //itemdata itemsbuf;
21327 for ( int32_t q = 0; q < MAXITEMS; q++ )
21328 {
21329 if ( itemsbuf[q].family == itype_candle )
21330 {
21331 if ( hurtshero ) itemsbuf[q].flags |= ITEM_FLAG2;
21332 else itemsbuf[q].flags &= ~ ITEM_FLAG2;
21333 }
21334 }
21335 }
21336
21337 void portBombRules()
21338 {
21339 bool hurtshero = get_qr(qr_OUCHBOMBS);
21340 //itemdata itemsbuf;
21341 for ( int32_t q = 0; q < MAXITEMS; q++ )
21342 {
21343 if ( itemsbuf[q].family == itype_bomb )
21344 {
21345 if ( hurtshero ) itemsbuf[q].flags |= ITEM_FLAG2;
21346 else itemsbuf[q].flags &= ~ ITEM_FLAG2;
21347 }
21348 }
21349 }
21350
21351 3008 static int section_id_to_enum(int id)
21352 {
21353
24/27
✗ Branch 0 not taken.
✓ Branch 1 taken 131 times.
✓ Branch 2 taken 131 times.
✓ Branch 3 taken 131 times.
✓ Branch 4 taken 131 times.
✓ Branch 5 taken 131 times.
✓ Branch 6 taken 115 times.
✓ Branch 7 taken 131 times.
✓ Branch 8 taken 131 times.
✓ Branch 9 taken 131 times.
✓ Branch 10 taken 131 times.
✓ Branch 11 taken 131 times.
✓ Branch 12 taken 131 times.
✓ Branch 13 taken 115 times.
✓ Branch 14 taken 115 times.
✓ Branch 15 taken 131 times.
✓ Branch 16 taken 131 times.
✓ Branch 17 taken 119 times.
✓ Branch 18 taken 115 times.
✓ Branch 19 taken 115 times.
✓ Branch 20 taken 115 times.
✓ Branch 21 taken 131 times.
✓ Branch 22 taken 131 times.
✓ Branch 23 taken 119 times.
✓ Branch 24 taken 115 times.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
3008 switch (id)
21354 {
21355 case ID_HEADER: return skip_header;
21356 131 case ID_RULES: return skip_rules;
21357 131 case ID_STRINGS: return skip_strings;
21358 131 case ID_MISC: return skip_misc;
21359 131 case ID_TILES: return skip_tiles;
21360 131 case ID_COMBOS: return skip_combos;
21361 115 case ID_COMBOALIASES: return skip_comboaliases;
21362 131 case ID_CSETS: return skip_csets;
21363 131 case ID_MAPS: return skip_maps;
21364 131 case ID_DMAPS: return skip_dmaps;
21365 131 case ID_DOORS: return skip_doors;
21366 131 case ID_ITEMS: return skip_items;
21367 131 case ID_WEAPONS: return skip_weapons;
21368 115 case ID_COLORS: return skip_colors;
21369 115 case ID_ICONS: return skip_icons;
21370 131 case ID_INITDATA: return skip_initdata;
21371 131 case ID_GUYS: return skip_guys;
21372 119 case ID_HEROSPRITES: return skip_herosprites;
21373 115 case ID_SUBSCREEN: return skip_subscreens;
21374 115 case ID_FFSCRIPT: return skip_ffscript;
21375 115 case ID_SFX: return skip_sfx;
21376 131 case ID_MIDIS: return skip_midis;
21377 131 case ID_CHEATS: return skip_cheats;
21378 119 case ID_ITEMDROPSETS: return skip_itemdropsets;
21379 115 case ID_FAVORITES: return skip_favorites;
21380 case ID_ZINFO: return skip_zinfo;
21381 }
21382
21383 return -1;
21384 3008 }
21385
21386 2940 static int maybe_skip_section(PACKFILE* f, dword& section_id, const byte* skip_flags)
21387 {
21388 2940 int section_enum = section_id_to_enum(section_id);
21389
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2940 times.
2940 bool skip = section_enum >= 0 && get_bit(skip_flags, section_enum);
21390
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2940 times.
2940 if (skip)
21391 {
21392 word s_version;
21393 if (!p_igetw(&s_version,f))
21394 {
21395 return qe_invalid;
21396 }
21397
21398 word c_version;
21399 if (!p_igetw(&c_version,f))
21400 {
21401 return qe_invalid;
21402 }
21403
21404 if (section_id == ID_RULES && s_version > 16)
21405 {
21406 dword dummy;
21407 if (!p_igetl(&dummy,f))
21408 {
21409 return qe_invalid;
21410 }
21411 }
21412
21413 if (section_id == ID_FFSCRIPT && s_version >= 18)
21414 {
21415 word dummy;
21416 if (!p_igetw(&dummy,f))
21417 {
21418 return qe_invalid;
21419 }
21420 }
21421
21422 dword section_length;
21423 if (!p_igetl(&section_length,f))
21424 {
21425 return qe_invalid;
21426 }
21427
21428 if (pack_fseek(f, section_length))
21429 {
21430 return qe_invalid;
21431 }
21432
21433 if (!pack_feof(f))
21434 {
21435 if (!p_mgetl(&section_id,f))
21436 {
21437 return qe_invalid;
21438 }
21439 }
21440
21441 return qe_cancel;
21442 }
21443
21444 2940 return qe_OK;
21445 2940 }
21446
21447 //Internal function for loadquest wrapper
21448 131 static int32_t _lq_int(const char *filename, zquestheader *Header, miscQdata *Misc, zctune *tunes, bool show_progress, byte *skip_flags, byte printmetadata)
21449 {
21450 131 DMapEditorLastMaptileUsed = 0;
21451 131 combosread=false;
21452 131 mapsread=false;
21453 131 fixffcs=false;
21454
21455 131 bool do_clear_scripts = !get_bit(skip_flags,skip_ffscript);
21456
1/2
✓ Branch 0 taken 131 times.
✗ Branch 1 not taken.
131 if(loading_tileset_flags & TILESET_CLEARSCRIPTS)
21457 {
21458 set_bit(skip_flags, skip_ffscript, 1);
21459 setZScriptVersion(V_FFSCRIPT);
21460 FFCore.quest_format[vFFScript] = V_FFSCRIPT;
21461 FFCore.quest_format[vLastCompile] = V_FFSCRIPT;
21462 do_clear_scripts = true;
21463 }
21464
1/2
✓ Branch 0 taken 131 times.
✗ Branch 1 not taken.
131 if(loading_tileset_flags & TILESET_CLEARMAPS)
21465 {
21466 set_bit(skip_flags, skip_maps, 1);
21467 }
21468
21469 // show_progress=true;
21470 char tmpfilename[L_tmpnam];
21471 131 temp_name(tmpfilename);
21472 // char percent_done[30];
21473 131 bool catchup=false;
21474 byte tempbyte;
21475 131 word old_map_count=map_count;
21476
21477 131 byte old_quest_rules[QUESTRULES_NEW_SIZE] = {0};
21478 131 byte old_extra_rules[EXTRARULES_SIZE] = {0};
21479 131 byte old_midi_flags[MIDIFLAGS_SIZE] = {0};
21480
21481
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 131 times.
131 if(get_bit(skip_flags, skip_rules))
21482 {
21483 memcpy(old_quest_rules, quest_rules, QUESTRULES_NEW_SIZE);
21484 memcpy(old_extra_rules, extra_rules, EXTRARULES_SIZE);
21485 }
21486
21487 131 memset(quest_rules, 0, QUESTRULES_NEW_SIZE); //clear here to prevent any kind of carryover -Z
21488 131 unpack_qrs();
21489 // memset(extra_rules, 0, EXTRARULES_SIZE); //clear here to prevent any kind of carryover -Z
21490
21491
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 131 times.
131 if(get_bit(skip_flags, skip_midis))
21492 {
21493 memcpy(old_midi_flags, midi_flags, MIDIFLAGS_SIZE);
21494 }
21495
21496
21497
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 131 times.
131 if(do_clear_scripts)
21498 {
21499 131 zScript.clear();
21500 131 globalmap.clear();
21501 131 genericmap.clear();
21502 131 ffcmap.clear();
21503 131 itemmap.clear();
21504 131 npcmap.clear();
21505 131 ewpnmap.clear();
21506 131 lwpnmap.clear();
21507 131 playermap.clear();
21508 131 dmapmap.clear();
21509 131 screenmap.clear();
21510 131 itemspritemap.clear();
21511 131 comboscriptmap.clear();
21512 131 subscreenmap.clear();
21513
21514
2/2
✓ Branch 0 taken 66941 times.
✓ Branch 1 taken 131 times.
67072 for(int32_t i=0; i<NUMSCRIPTFFC-1; i++)
21515 {
21516 66941 ffcmap[i].clear();
21517 66941 }
21518
21519 131 globalmap[0].slotname = "Slot 1:";
21520 131 globalmap[0].scriptname = "~Init";
21521 131 globalmap[0].update();
21522
21523
2/2
✓ Branch 0 taken 917 times.
✓ Branch 1 taken 131 times.
1048 for(int32_t i=1; i<NUMSCRIPTGLOBAL; i++)
21524 {
21525 917 globalmap[i].clear();
21526 917 }
21527
21528
2/2
✓ Branch 0 taken 33405 times.
✓ Branch 1 taken 131 times.
33536 for(int32_t i=0; i<NUMSCRIPTITEM-1; i++)
21529 {
21530 33405 itemmap[i].clear();
21531 33405 }
21532
21533 //new script types -- prevent carrying over to a quest that you load after reading them
21534 //e.g., a quest has an npc script, and you make a blank quest, that now believes that it has an npc script, too!
21535
2/2
✓ Branch 0 taken 33405 times.
✓ Branch 1 taken 131 times.
33536 for(int32_t i=0; i<NUMSCRIPTGUYS-1; i++)
21536 {
21537 33405 npcmap[i].clear();
21538 33405 }
21539
2/2
✓ Branch 0 taken 33405 times.
✓ Branch 1 taken 131 times.
33536 for(int32_t i=0; i<NUMSCRIPTWEAPONS-1; i++)
21540 {
21541 33405 lwpnmap[i].clear();
21542 33405 }
21543
2/2
✓ Branch 0 taken 33405 times.
✓ Branch 1 taken 131 times.
33536 for(int32_t i=0; i<NUMSCRIPTWEAPONS-1; i++)
21544 {
21545 33405 ewpnmap[i].clear();
21546 33405 }
21547
2/2
✓ Branch 0 taken 524 times.
✓ Branch 1 taken 131 times.
655 for(int32_t i=0; i<NUMSCRIPTPLAYER-1; i++)
21548 {
21549 524 playermap[i].clear();
21550 524 }
21551
2/2
✓ Branch 0 taken 33405 times.
✓ Branch 1 taken 131 times.
33536 for(int32_t i=0; i<NUMSCRIPTSDMAP-1; i++)
21552 {
21553 33405 dmapmap[i].clear();
21554 33405 }
21555
2/2
✓ Branch 0 taken 33405 times.
✓ Branch 1 taken 131 times.
33536 for(int32_t i=0; i<NUMSCRIPTSCREEN-1; i++)
21556 {
21557 33405 screenmap[i].clear();
21558 33405 }
21559
2/2
✓ Branch 0 taken 33405 times.
✓ Branch 1 taken 131 times.
33536 for(int32_t i=0; i<NUMSCRIPTSITEMSPRITE-1; i++)
21560 {
21561 33405 itemspritemap[i].clear();
21562 33405 }
21563
2/2
✓ Branch 0 taken 66941 times.
✓ Branch 1 taken 131 times.
67072 for(int32_t i=0; i<NUMSCRIPTSCOMBODATA-1; i++)
21564 {
21565 66941 comboscriptmap[i].clear();
21566 66941 }
21567
2/2
✓ Branch 0 taken 66941 times.
✓ Branch 1 taken 131 times.
67072 for(int32_t i=0; i<NUMSCRIPTSGENERIC-1; i++)
21568 {
21569 66941 genericmap[i].clear();
21570 66941 }
21571
2/2
✓ Branch 0 taken 33405 times.
✓ Branch 1 taken 131 times.
33536 for(int32_t i=0; i<NUMSCRIPTSSUBSCREEN-1; i++)
21572 {
21573 33405 subscreenmap[i].clear();
21574 33405 }
21575
21576 131 reset_scripts();
21577 131 }
21578
21579 zquestheader tempheader;
21580 131 memset(&tempheader, 0, sizeof(zquestheader));
21581 131 zinfo tempzi;
21582 131 tempzi.clear();
21583 131 load_tmp_zi = &tempzi;
21584
21585 // oldquest flag is set when an unencrypted qst file is suspected.
21586 131 bool oldquest = false;
21587 131 int32_t open_error=0;
21588 131 PACKFILE *f=open_quest_file(&open_error, filename, show_progress);
21589
21590
1/2
✓ Branch 0 taken 131 times.
✗ Branch 1 not taken.
131 if (!f)
21591 {
21592 ASSERT(open_error != 0);
21593 return open_error;
21594 }
21595 char zinfofilename[2048];
21596 131 replace_extension(zinfofilename, filename, "zinfo", 2047);
21597 131 int32_t ret=0;
21598
21599 //header
21600 131 box_out("Reading Header...");
21601 131 ret=readheader(f, &tempheader, printmetadata);
21602
1/5
✗ Branch 0 not taken.
✓ Branch 1 taken 131 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
131 checkstatus(ret);
21603 131 box_out("okay.");
21604 131 box_eol();
21605
21606
2/2
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 38 times.
131 if(read_zinfo)
21607 {
21608 38 box_out("Reading ZInfo - ");
21609
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 37 times.
38 box_out(read_ext_zinfo ? "External..." : "Internal...");
21610
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 37 times.
38 if(read_ext_zinfo)
21611 {
21612 1 PACKFILE *inf=pack_fopen_password(zinfofilename, F_READ, "");
21613 1 ret=readzinfo(inf, tempzi, tempheader);
21614
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if(inf) pack_fclose(inf);
21615
1/5
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
1 checkstatus(ret);
21616 1 }
21617 else
21618 {
21619 37 ret=readzinfo(f, tempzi, tempheader);
21620
1/5
✗ Branch 0 not taken.
✓ Branch 1 taken 37 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
37 checkstatus(ret);
21621 }
21622 38 box_out("okay.");
21623 38 box_eol();
21624 38 }
21625
21626
2/2
✓ Branch 0 taken 127 times.
✓ Branch 1 taken 4 times.
131 if(tempheader.zelda_version>=0x193)
21627 {
21628 dword section_id;
21629
21630 //section id
21631
1/2
✓ Branch 0 taken 127 times.
✗ Branch 1 not taken.
127 if(!p_mgetl(&section_id,f))
21632 {
21633 return qe_invalid;
21634 }
21635
21636 127 std::set<dword> seen_sections;
21637
21638
3/4
✓ Branch 0 taken 3067 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2940 times.
✓ Branch 3 taken 127 times.
3067 while(!pack_feof(f))
21639 {
21640
2/4
✓ Branch 0 taken 2940 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2940 times.
✗ Branch 3 not taken.
2940 if (seen_sections.contains(section_id))
21641 return qe_invalid;
21642
1/2
✓ Branch 0 taken 2940 times.
✗ Branch 1 not taken.
2940 seen_sections.insert(section_id);
21643
21644
2/4
✓ Branch 0 taken 2940 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2940 times.
✗ Branch 3 not taken.
2940 if (int retval = maybe_skip_section(f, section_id, skip_flags); retval != qe_OK)
21645 {
21646 if (retval == qe_cancel)
21647 continue;
21648 checkstatus(retval);
21649 }
21650
21651
24/25
✓ Branch 0 taken 127 times.
✓ Branch 1 taken 127 times.
✓ Branch 2 taken 127 times.
✓ Branch 3 taken 127 times.
✓ Branch 4 taken 127 times.
✓ Branch 5 taken 115 times.
✓ Branch 6 taken 127 times.
✓ Branch 7 taken 127 times.
✓ Branch 8 taken 127 times.
✓ Branch 9 taken 127 times.
✓ Branch 10 taken 127 times.
✓ Branch 11 taken 127 times.
✓ Branch 12 taken 115 times.
✓ Branch 13 taken 115 times.
✓ Branch 14 taken 127 times.
✓ Branch 15 taken 127 times.
✓ Branch 16 taken 115 times.
✓ Branch 17 taken 115 times.
✓ Branch 18 taken 115 times.
✓ Branch 19 taken 115 times.
✓ Branch 20 taken 127 times.
✓ Branch 21 taken 127 times.
✓ Branch 22 taken 115 times.
✓ Branch 23 taken 115 times.
✗ Branch 24 not taken.
2940 switch(section_id)
21652 {
21653 case ID_RULES:
21654
21655 //rules
21656
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 127 times.
127 if(catchup)
21657 {
21658 box_out("found.");
21659 box_eol();
21660 catchup=false;
21661 }
21662
21663
1/2
✓ Branch 0 taken 127 times.
✗ Branch 1 not taken.
127 box_out("Reading Rules...");
21664
1/2
✓ Branch 0 taken 127 times.
✗ Branch 1 not taken.
127 ret=readrules(f, &tempheader);
21665
1/9
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 127 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
127 checkstatus(ret);
21666
1/2
✓ Branch 0 taken 127 times.
✗ Branch 1 not taken.
127 box_out("okay.");
21667
1/2
✓ Branch 0 taken 127 times.
✗ Branch 1 not taken.
127 box_eol();
21668 127 break;
21669
21670 case ID_STRINGS:
21671
21672 //strings
21673
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 127 times.
127 if(catchup)
21674 {
21675 box_out("found.");
21676 box_eol();
21677 catchup=false;
21678 }
21679
21680
1/2
✓ Branch 0 taken 127 times.
✗ Branch 1 not taken.
127 box_out("Reading Strings...");
21681
1/2
✓ Branch 0 taken 127 times.
✗ Branch 1 not taken.
127 ret=readstrings(f, &tempheader);
21682
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 127 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
127 checkstatus(ret);
21683
1/2
✓ Branch 0 taken 127 times.
✗ Branch 1 not taken.
127 box_out("okay.");
21684
1/2
✓ Branch 0 taken 127 times.
✗ Branch 1 not taken.
127 box_eol();
21685 127 break;
21686
21687 case ID_MISC:
21688
21689 //misc data
21690
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 127 times.
127 if(catchup)
21691 {
21692 box_out("found.");
21693 box_eol();
21694 catchup=false;
21695 }
21696
21697
1/2
✓ Branch 0 taken 127 times.
✗ Branch 1 not taken.
127 box_out("Reading Misc. Data...");
21698
1/2
✓ Branch 0 taken 127 times.
✗ Branch 1 not taken.
127 ret=readmisc(f, &tempheader, Misc);
21699
1/9
✓ Branch 0 taken 127 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
127 checkstatus(ret);
21700
1/2
✓ Branch 0 taken 127 times.
✗ Branch 1 not taken.
127 box_out("okay.");
21701
1/2
✓ Branch 0 taken 127 times.
✗ Branch 1 not taken.
127 box_eol();
21702 127 break;
21703
21704 case ID_TILES:
21705
21706 //tiles
21707
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 127 times.
127 if(catchup)
21708 {
21709 box_out("found.");
21710 box_eol();
21711 catchup=false;
21712 }
21713
21714
1/2
✓ Branch 0 taken 127 times.
✗ Branch 1 not taken.
127 box_out("Reading Tiles...");
21715
1/2
✓ Branch 0 taken 127 times.
✗ Branch 1 not taken.
127 ret=readtiles(f, newtilebuf, &tempheader, tempheader.zelda_version, tempheader.build, 0, NEWMAXTILES, false);
21716
1/9
✓ Branch 0 taken 127 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
127 checkstatus(ret);
21717
1/2
✓ Branch 0 taken 127 times.
✗ Branch 1 not taken.
127 box_out("okay.");
21718
1/2
✓ Branch 0 taken 127 times.
✗ Branch 1 not taken.
127 box_eol();
21719 127 break;
21720
21721 case ID_COMBOS:
21722
21723 //combos
21724
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 127 times.
127 if(catchup)
21725 {
21726 box_out("found.");
21727 box_eol();
21728 catchup=false;
21729 }
21730
21731
1/2
✓ Branch 0 taken 127 times.
✗ Branch 1 not taken.
127 box_out("Reading Combos...");
21732
1/2
✓ Branch 0 taken 127 times.
✗ Branch 1 not taken.
127 ret=readcombos(f, &tempheader, tempheader.zelda_version, tempheader.build, 0, MAXCOMBOS);
21733 127 combosread=true;
21734
1/9
✓ Branch 0 taken 127 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
127 checkstatus(ret);
21735
1/2
✓ Branch 0 taken 127 times.
✗ Branch 1 not taken.
127 box_out("okay.");
21736
1/2
✓ Branch 0 taken 127 times.
✗ Branch 1 not taken.
127 box_eol();
21737 127 break;
21738
21739 case ID_COMBOALIASES:
21740
21741 //combo aliases
21742
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 115 times.
115 if(catchup)
21743 {
21744 box_out("found.");
21745 box_eol();
21746 catchup=false;
21747 }
21748
21749
1/2
✓ Branch 0 taken 115 times.
✗ Branch 1 not taken.
115 box_out("Reading Combo Aliases...");
21750
1/2
✓ Branch 0 taken 115 times.
✗ Branch 1 not taken.
115 ret=readcomboaliases(f, &tempheader, tempheader.zelda_version, tempheader.build);
21751
1/9
✓ Branch 0 taken 115 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
115 checkstatus(ret);
21752
1/2
✓ Branch 0 taken 115 times.
✗ Branch 1 not taken.
115 box_out("okay.");
21753
1/2
✓ Branch 0 taken 115 times.
✗ Branch 1 not taken.
115 box_eol();
21754 115 break;
21755
21756 case ID_CSETS:
21757
21758 //color data
21759
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 127 times.
127 if(catchup)
21760 {
21761 box_out("found.");
21762 box_eol();
21763 catchup=false;
21764 }
21765
21766
1/2
✓ Branch 0 taken 127 times.
✗ Branch 1 not taken.
127 box_out("Reading Color Data...");
21767
1/2
✓ Branch 0 taken 127 times.
✗ Branch 1 not taken.
127 ret=readcolordata(f, Misc, tempheader.zelda_version, tempheader.build, 0, newerpdTOTAL);
21768
1/9
✓ Branch 0 taken 127 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
127 checkstatus(ret);
21769
1/2
✓ Branch 0 taken 127 times.
✗ Branch 1 not taken.
127 box_out("okay.");
21770
1/2
✓ Branch 0 taken 127 times.
✗ Branch 1 not taken.
127 box_eol();
21771 127 break;
21772
21773 case ID_MAPS:
21774
21775 //maps
21776
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 127 times.
127 if(catchup)
21777 {
21778 box_out("found.");
21779 box_eol();
21780 catchup=false;
21781 }
21782
21783
1/2
✓ Branch 0 taken 127 times.
✗ Branch 1 not taken.
127 box_out("Reading Maps...");
21784
1/2
✓ Branch 0 taken 127 times.
✗ Branch 1 not taken.
127 ret=readmaps(f, &tempheader);
21785 127 mapsread=true;
21786
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 127 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
127 checkstatus(ret);
21787
1/2
✓ Branch 0 taken 127 times.
✗ Branch 1 not taken.
127 box_out("okay.");
21788
1/2
✓ Branch 0 taken 127 times.
✗ Branch 1 not taken.
127 box_eol();
21789 127 break;
21790
21791 case ID_DMAPS:
21792
21793 //dmaps
21794
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 127 times.
127 if(catchup)
21795 {
21796 box_out("found.");
21797 box_eol();
21798 catchup=false;
21799 }
21800
21801
1/2
✓ Branch 0 taken 127 times.
✗ Branch 1 not taken.
127 box_out("Reading DMaps...");
21802
1/2
✓ Branch 0 taken 127 times.
✗ Branch 1 not taken.
127 ret=readdmaps(f, &tempheader, tempheader.zelda_version, tempheader.build, 0, MAXDMAPS);
21803
1/9
✓ Branch 0 taken 127 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
127 checkstatus(ret);
21804
1/2
✓ Branch 0 taken 127 times.
✗ Branch 1 not taken.
127 box_out("okay.");
21805
1/2
✓ Branch 0 taken 127 times.
✗ Branch 1 not taken.
127 box_eol();
21806 127 break;
21807
21808 case ID_DOORS:
21809
21810 //door combo sets
21811
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 127 times.
127 if(catchup)
21812 {
21813 box_out("found.");
21814 box_eol();
21815 catchup=false;
21816 }
21817
21818
1/2
✓ Branch 0 taken 127 times.
✗ Branch 1 not taken.
127 box_out("Reading Doors...");
21819
1/2
✓ Branch 0 taken 127 times.
✗ Branch 1 not taken.
127 ret=readdoorcombosets(f, &tempheader);
21820
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 127 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
127 checkstatus(ret);
21821
1/2
✓ Branch 0 taken 127 times.
✗ Branch 1 not taken.
127 box_out("okay.");
21822
1/2
✓ Branch 0 taken 127 times.
✗ Branch 1 not taken.
127 box_eol();
21823 127 break;
21824
21825 case ID_ITEMS:
21826
21827 //items
21828
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 127 times.
127 if(catchup)
21829 {
21830 box_out("found.");
21831 box_eol();
21832 catchup=false;
21833 }
21834
21835
1/2
✓ Branch 0 taken 127 times.
✗ Branch 1 not taken.
127 box_out("Reading Items...");
21836
1/2
✓ Branch 0 taken 127 times.
✗ Branch 1 not taken.
127 ret=readitems(f, tempheader.zelda_version, tempheader.build);
21837
1/9
✓ Branch 0 taken 127 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
127 checkstatus(ret);
21838
21839
1/2
✓ Branch 0 taken 127 times.
✗ Branch 1 not taken.
127 box_out("okay.");
21840
1/2
✓ Branch 0 taken 127 times.
✗ Branch 1 not taken.
127 box_eol();
21841 127 break;
21842
21843 case ID_WEAPONS:
21844
21845 //weapons
21846
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 127 times.
127 if(catchup)
21847 {
21848 box_out("found.");
21849 box_eol();
21850 catchup=false;
21851 }
21852
21853
1/2
✓ Branch 0 taken 127 times.
✗ Branch 1 not taken.
127 box_out("Reading Weapons...");
21854
1/2
✓ Branch 0 taken 127 times.
✗ Branch 1 not taken.
127 ret=readweapons(f, &tempheader);
21855
1/9
✓ Branch 0 taken 127 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
127 checkstatus(ret);
21856
1/2
✓ Branch 0 taken 127 times.
✗ Branch 1 not taken.
127 box_out("okay.");
21857
1/2
✓ Branch 0 taken 127 times.
✗ Branch 1 not taken.
127 box_eol();
21858 127 break;
21859
21860 case ID_COLORS:
21861
21862 //misc. colors
21863
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 115 times.
115 if(catchup)
21864 {
21865 box_out("found.");
21866 box_eol();
21867 catchup=false;
21868 }
21869
21870
1/2
✓ Branch 0 taken 115 times.
✗ Branch 1 not taken.
115 box_out("Reading Misc. Colors...");
21871
1/2
✓ Branch 0 taken 115 times.
✗ Branch 1 not taken.
115 ret=readmisccolors(f, &tempheader, Misc);
21872
1/9
✓ Branch 0 taken 115 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
115 checkstatus(ret);
21873
1/2
✓ Branch 0 taken 115 times.
✗ Branch 1 not taken.
115 box_out("okay.");
21874
1/2
✓ Branch 0 taken 115 times.
✗ Branch 1 not taken.
115 box_eol();
21875 115 break;
21876
21877 case ID_ICONS:
21878
21879 //game icons
21880
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 115 times.
115 if(catchup)
21881 {
21882 box_out("found.");
21883 box_eol();
21884 catchup=false;
21885 }
21886
21887
1/2
✓ Branch 0 taken 115 times.
✗ Branch 1 not taken.
115 box_out("Reading Game Icons...");
21888
1/2
✓ Branch 0 taken 115 times.
✗ Branch 1 not taken.
115 ret=readgameicons(f, &tempheader, Misc);
21889
1/9
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 115 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
115 checkstatus(ret);
21890
1/2
✓ Branch 0 taken 115 times.
✗ Branch 1 not taken.
115 box_out("okay.");
21891
1/2
✓ Branch 0 taken 115 times.
✗ Branch 1 not taken.
115 box_eol();
21892 115 break;
21893
21894 case ID_INITDATA:
21895
21896 //initialization data
21897
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 127 times.
127 if(catchup)
21898 {
21899 box_out("found.");
21900 box_eol();
21901 catchup=false;
21902 }
21903
21904
1/2
✓ Branch 0 taken 127 times.
✗ Branch 1 not taken.
127 box_out("Reading Init. Data...");
21905
1/2
✓ Branch 0 taken 127 times.
✗ Branch 1 not taken.
127 ret=readinitdata(f, &tempheader);
21906
1/9
✓ Branch 0 taken 127 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
127 checkstatus(ret);
21907
1/2
✓ Branch 0 taken 127 times.
✗ Branch 1 not taken.
127 box_out("okay.");
21908
1/2
✓ Branch 0 taken 127 times.
✗ Branch 1 not taken.
127 box_eol();
21909
21910
2/4
✓ Branch 0 taken 127 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 127 times.
127 if(!get_bit(skip_flags, skip_subscreens))
21911 {
21912
2/2
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 100 times.
127 if(subscr_mode!=ssdtMAX) //not using custom subscreens
21913 {
21914
1/2
✓ Branch 0 taken 27 times.
✗ Branch 1 not taken.
27 setupsubscreens();
21915
21916
2/2
✓ Branch 0 taken 13824 times.
✓ Branch 1 taken 27 times.
13851 for(int32_t i=0; i<MAXDMAPS; ++i)
21917 {
21918 13824 int32_t type=DMaps[i].type&dmfTYPE;
21919
2/2
✓ Branch 0 taken 207 times.
✓ Branch 1 taken 13617 times.
13824 DMaps[i].active_subscreen=(type == dmOVERW || type == dmBSOVERW)?0:1;
21920 13824 DMaps[i].passive_subscreen=(get_qr(qr_ENABLEMAGIC))?0:1;
21921 13824 }
21922 27 }
21923 127 }
21924
21925
2/4
✓ Branch 0 taken 127 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 127 times.
127 if(!get_bit(skip_flags, skip_sfx))
21926 {
21927 127 setupsfx();
21928 127 }
21929
21930
2/4
✓ Branch 0 taken 127 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 127 times.
✗ Branch 3 not taken.
127 if(!get_bit(skip_flags, skip_itemdropsets))
21931 {
21932
1/2
✓ Branch 0 taken 127 times.
✗ Branch 1 not taken.
127 init_item_drop_sets();
21933 127 }
21934
21935
2/4
✓ Branch 0 taken 127 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 127 times.
127 if(!get_bit(skip_flags, skip_favorites))
21936 {
21937 127 init_favorites();
21938 127 }
21939
21940 127 break;
21941
21942 case ID_GUYS:
21943
21944 //guys
21945
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 127 times.
127 if(catchup)
21946 {
21947 box_out("found.");
21948 box_eol();
21949 catchup=false;
21950 }
21951
21952
1/2
✓ Branch 0 taken 127 times.
✗ Branch 1 not taken.
127 box_out("Reading Custom Guy Data...");
21953
1/2
✓ Branch 0 taken 127 times.
✗ Branch 1 not taken.
127 ret=readguys(f, &tempheader);
21954
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 127 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
127 checkstatus(ret);
21955
1/2
✓ Branch 0 taken 127 times.
✗ Branch 1 not taken.
127 box_out("okay.");
21956
1/2
✓ Branch 0 taken 127 times.
✗ Branch 1 not taken.
127 box_eol();
21957 127 break;
21958
21959 case ID_HEROSPRITES:
21960
21961 //player sprites
21962
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 115 times.
115 if(catchup)
21963 {
21964 box_out("found.");
21965 box_eol();
21966 catchup=false;
21967 }
21968
21969
1/2
✓ Branch 0 taken 115 times.
✗ Branch 1 not taken.
115 box_out("Reading Custom Player Sprite Data...");
21970
1/2
✓ Branch 0 taken 115 times.
✗ Branch 1 not taken.
115 ret=readherosprites(f, &tempheader);
21971
1/9
✓ Branch 0 taken 115 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
115 checkstatus(ret);
21972
1/2
✓ Branch 0 taken 115 times.
✗ Branch 1 not taken.
115 box_out("okay.");
21973
1/2
✓ Branch 0 taken 115 times.
✗ Branch 1 not taken.
115 box_eol();
21974 115 break;
21975
21976 case ID_SUBSCREEN:
21977
21978 //custom subscreens
21979
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 115 times.
115 if(catchup)
21980 {
21981 box_out("found.");
21982 box_eol();
21983 catchup=false;
21984 }
21985
21986
1/2
✓ Branch 0 taken 115 times.
✗ Branch 1 not taken.
115 box_out("Reading Custom Subscreen Data...");
21987
1/2
✓ Branch 0 taken 115 times.
✗ Branch 1 not taken.
115 ret=readsubscreens(f);
21988
1/9
✓ Branch 0 taken 115 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
115 checkstatus(ret);
21989
1/2
✓ Branch 0 taken 115 times.
✗ Branch 1 not taken.
115 box_out("okay.");
21990
1/2
✓ Branch 0 taken 115 times.
✗ Branch 1 not taken.
115 box_eol();
21991 115 break;
21992
21993 case ID_FFSCRIPT:
21994
21995 //Freeform combo scripts
21996
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 115 times.
115 if(catchup)
21997 {
21998 box_out("found.");
21999 box_eol();
22000 catchup=false;
22001 }
22002
22003
1/2
✓ Branch 0 taken 115 times.
✗ Branch 1 not taken.
115 box_out("Reading FF Script Data...");
22004
1/2
✓ Branch 0 taken 115 times.
✗ Branch 1 not taken.
115 ret=readffscript(f, &tempheader);
22005
1/9
✓ Branch 0 taken 115 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
115 checkstatus(ret);
22006
1/2
✓ Branch 0 taken 115 times.
✗ Branch 1 not taken.
115 box_out("okay.");
22007
1/2
✓ Branch 0 taken 115 times.
✗ Branch 1 not taken.
115 box_eol();
22008 115 break;
22009
22010 case ID_SFX:
22011
22012 //SFX data
22013
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 115 times.
115 if(catchup)
22014 {
22015 box_out("found.");
22016 box_eol();
22017 catchup=false;
22018 }
22019
22020
1/2
✓ Branch 0 taken 115 times.
✗ Branch 1 not taken.
115 box_out("Reading SFX Data...");
22021
1/2
✓ Branch 0 taken 115 times.
✗ Branch 1 not taken.
115 ret=readsfx(f, &tempheader);
22022
1/9
✓ Branch 0 taken 115 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
115 checkstatus(ret);
22023
1/2
✓ Branch 0 taken 115 times.
✗ Branch 1 not taken.
115 box_out("okay.");
22024
1/2
✓ Branch 0 taken 115 times.
✗ Branch 1 not taken.
115 box_eol();
22025 115 break;
22026
22027 case ID_MIDIS:
22028
22029 //midis
22030
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 127 times.
127 if(catchup)
22031 {
22032 box_out("found.");
22033 box_eol();
22034 catchup=false;
22035 }
22036
22037
1/2
✓ Branch 0 taken 127 times.
✗ Branch 1 not taken.
127 box_out("Reading Tunes...");
22038
1/2
✓ Branch 0 taken 127 times.
✗ Branch 1 not taken.
127 ret=readtunes(f, &tempheader, tunes);
22039
1/9
✓ Branch 0 taken 127 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
127 checkstatus(ret);
22040
1/2
✓ Branch 0 taken 127 times.
✗ Branch 1 not taken.
127 box_out("okay.");
22041
1/2
✓ Branch 0 taken 127 times.
✗ Branch 1 not taken.
127 box_eol();
22042 127 break;
22043
22044 case ID_CHEATS:
22045
22046 //cheat codes
22047
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 127 times.
127 if(catchup)
22048 {
22049 box_out("found.");
22050 box_eol();
22051 catchup=false;
22052 }
22053
22054
1/2
✓ Branch 0 taken 127 times.
✗ Branch 1 not taken.
127 box_out("Reading Cheat Codes...");
22055
1/2
✓ Branch 0 taken 127 times.
✗ Branch 1 not taken.
127 ret=readcheatcodes(f, &tempheader);
22056
1/9
✓ Branch 0 taken 127 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
127 checkstatus(ret);
22057
1/2
✓ Branch 0 taken 127 times.
✗ Branch 1 not taken.
127 box_out("okay.");
22058
1/2
✓ Branch 0 taken 127 times.
✗ Branch 1 not taken.
127 box_eol();
22059 127 break;
22060
22061 case ID_ITEMDROPSETS:
22062
22063 //item drop sets
22064
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 115 times.
115 if(catchup)
22065 {
22066 box_out("found.");
22067 box_eol();
22068 catchup=false;
22069 }
22070
22071
1/2
✓ Branch 0 taken 115 times.
✗ Branch 1 not taken.
115 box_out("Reading Item Drop Sets...");
22072
1/2
✓ Branch 0 taken 115 times.
✗ Branch 1 not taken.
115 ret=readitemdropsets(f, tempheader.zelda_version, tempheader.build);
22073
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 115 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
115 checkstatus(ret);
22074
1/2
✓ Branch 0 taken 115 times.
✗ Branch 1 not taken.
115 box_out("okay.");
22075
1/2
✓ Branch 0 taken 115 times.
✗ Branch 1 not taken.
115 box_eol();
22076 115 break;
22077
22078 case ID_FAVORITES:
22079
22080 //favorite combos and combo aliases
22081
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 115 times.
115 if(catchup)
22082 {
22083 box_out("found.");
22084 box_eol();
22085 catchup=false;
22086 }
22087
22088
1/2
✓ Branch 0 taken 115 times.
✗ Branch 1 not taken.
115 box_out("Reading Favorite Combos...");
22089
1/2
✓ Branch 0 taken 115 times.
✗ Branch 1 not taken.
115 ret=readfavorites(f, tempheader.zelda_version, tempheader.build);
22090
1/9
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 115 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
115 checkstatus(ret);
22091
1/2
✓ Branch 0 taken 115 times.
✗ Branch 1 not taken.
115 box_out("okay.");
22092
1/2
✓ Branch 0 taken 115 times.
✗ Branch 1 not taken.
115 box_eol();
22093 115 break;
22094
22095 default:
22096 if(!catchup)
22097 {
22098 box_out("Bad token! Searching...");
22099 box_eol();
22100 }
22101
22102 catchup=true;
22103 break;
22104 }
22105
22106
22107
1/2
✓ Branch 0 taken 2940 times.
✗ Branch 1 not taken.
2940 if(catchup)
22108 {
22109 //section id
22110 section_id=(section_id<<8);
22111
22112 if(!p_getc(&tempbyte,f))
22113 {
22114 return qe_invalid;
22115 }
22116
22117 section_id+=tempbyte;
22118 }
22119
22120 else
22121 {
22122 //section id
22123
3/4
✓ Branch 0 taken 2940 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2813 times.
✓ Branch 3 taken 127 times.
2940 if(!pack_feof(f))
22124 {
22125
2/4
✓ Branch 0 taken 2813 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2813 times.
✗ Branch 3 not taken.
2813 if(!p_mgetl(&section_id,f))
22126 {
22127 return qe_invalid;
22128 }
22129 2813 }
22130 }
22131 }
22132
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 127 times.
127 }
22133 else
22134 {
22135
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 std::vector<std::tuple<std::string, int32_t, std::function<int32_t()>>> hardcoded_sections = {
22136
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
8 { "Rules", ID_RULES, [&](){ return readrules(f, &tempheader); }},
22137
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
8 { "Strings", ID_STRINGS, [&](){ return readstrings(f, &tempheader); }},
22138
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
8 { "Doors", ID_DOORS, [&](){ return readdoorcombosets(f, &tempheader); }},
22139
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
8 { "DMaps", ID_DMAPS, [&](){ return readdmaps(f, &tempheader, tempheader.zelda_version, tempheader.build, 0, MAXDMAPS); }},
22140
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
8 { "Misc. Data", ID_MISC, [&](){ return readmisc(f, &tempheader, Misc); }},
22141
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
8 { "Items", ID_ITEMS, [&](){ return readitems(f, tempheader.zelda_version, tempheader.build); }},
22142
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
8 { "Weapons", ID_WEAPONS, [&](){ return readweapons(f, &tempheader); }},
22143
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
8 { "Custom Guy Data", ID_GUYS, [&](){ return readguys(f, &tempheader); }},
22144
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
8 { "Maps", ID_MAPS, [&](){ return readmaps(f, &tempheader); }},
22145
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
8 { "Combos", ID_COMBOS, [&](){ return readcombos(f, &tempheader, tempheader.zelda_version, tempheader.build, 0, MAXCOMBOS); }},
22146
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
8 { "Color Data", ID_CSETS, [&](){ return readcolordata(f, Misc, tempheader.zelda_version, tempheader.build, 0, newerpdTOTAL); }},
22147
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
8 { "Tiles", ID_TILES, [&](){ return readtiles(f, newtilebuf, &tempheader, tempheader.zelda_version, tempheader.build, 0, NEWMAXTILES, false); }},
22148
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
8 { "Tunes", ID_MIDIS, [&](){ return readtunes(f, &tempheader, tunes); }},
22149
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
8 { "Cheat Codes", ID_CHEATS, [&](){ return readcheatcodes(f, &tempheader); }},
22150
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
8 { "Init. Data", ID_INITDATA, [&](){ return readinitdata(f, &tempheader); }},
22151
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
8 { "Custom Player Sprite Data", ID_HEROSPRITES, [&](){ return readherosprites2(f, -1, 0); }},
22152
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
8 { "Up Default Item Drop Sets", ID_ITEMDROPSETS, [&](){ return readitemdropsets(f, -1, 0); }},
22153 };
22154
22155 4 legacy_skip_flags = skip_flags;
22156
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 68 times.
208 for (auto& [desc, section_id, fn] : hardcoded_sections)
22157 {
22158
1/2
✓ Branch 0 taken 68 times.
✗ Branch 1 not taken.
68 int section_enum = section_id_to_enum(section_id);
22159
2/4
✓ Branch 0 taken 68 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 68 times.
✗ Branch 3 not taken.
68 bool skip = section_enum >= 0 && get_bit(skip_flags, section_enum);
22160
1/2
✓ Branch 0 taken 68 times.
✗ Branch 1 not taken.
68 if (skip)
22161 {
22162 // Nothing to read.
22163 if (section_id == ID_RULES)
22164 continue;
22165 if (section_id == ID_GUYS)
22166 continue;
22167
22168 // Haven't looked at how to skip these, because we don't need to currently: the only
22169 // usage of skip_flags currently is all off except: header and tiles (see `load_imagebuf`).
22170 if (section_id == ID_MIDIS)
22171 continue;
22172 if (section_id == ID_CHEATS)
22173 continue;
22174 if (section_id == ID_INITDATA)
22175 continue;
22176 if (section_id == ID_HEROSPRITES)
22177 continue;
22178 if (section_id == ID_ITEMDROPSETS)
22179 continue;
22180 }
22181
22182 // Would be nice, but old sections mostly did not save section sizes. We could advance by
22183 // a specific amount, but it'd be a lot of work to get it right. So, for old quests, let's just
22184 // read all the sections even if requested to skip some.
22185 // if (int retval = maybe_skip_section(f, section_id, skip_flags); retval != qe_OK)
22186 // {
22187 // if (retval == qe_cancel)
22188 // continue;
22189 // checkstatus(retval);
22190 // }
22191
22192
3/6
✓ Branch 0 taken 68 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 68 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 68 times.
✗ Branch 5 not taken.
136 box_out(fmt::format("Reading {}...", desc).c_str());
22193
1/2
✓ Branch 0 taken 68 times.
✗ Branch 1 not taken.
68 ret = fn();
22194
1/9
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 68 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
68 checkstatus(ret);
22195
1/2
✓ Branch 0 taken 68 times.
✗ Branch 1 not taken.
68 box_out("okay.");
22196
1/2
✓ Branch 0 taken 68 times.
✗ Branch 1 not taken.
68 box_eol();
22197 }
22198 4 legacy_skip_flags = nullptr;
22199
22200
2/4
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
4 if(!get_bit(skip_flags, skip_subscreens))
22201 {
22202
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 setupsubscreens();
22203
22204
2/2
✓ Branch 0 taken 2048 times.
✓ Branch 1 taken 4 times.
2052 for(int32_t i=0; i<MAXDMAPS; ++i)
22205 {
22206 2048 int32_t type=DMaps[i].type&dmfTYPE;
22207
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 2036 times.
2048 DMaps[i].active_subscreen=(type == dmOVERW || type == dmBSOVERW)?0:1;
22208 2048 DMaps[i].passive_subscreen=(get_qr(qr_ENABLEMAGIC))?0:1;
22209 2048 }
22210 4 }
22211
22212
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 box_out("Setting Up Default Sound Effects...");
22213
22214
2/4
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
4 if(!get_bit(skip_flags, skip_sfx))
22215 4 setupsfx();
22216
22217
2/4
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
4 if(!get_bit(skip_flags, skip_favorites))
22218 4 init_favorites();
22219
22220
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 box_out("okay.");
22221
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 box_eol();
22222
1/3
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
4 }
22223
22224 131 init_spritelists();
22225
22226 // check data
22227
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 131 times.
131 if(f)
22228 {
22229 131 pack_fclose(f);
22230 131 }
22231 131 clear_quest_tmpfile();
22232
22233
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 131 times.
131 if(!oldquest)
22234 {
22235
1/2
✓ Branch 0 taken 131 times.
✗ Branch 1 not taken.
131 if(exists(tmpfilename))
22236 {
22237 delete_file(tmpfilename);
22238 }
22239 131 }
22240
22241
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 131 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
131 if(fixffcs && combosread && mapsread)
22242 {
22243 for(int32_t i=0; i<map_count; i++)
22244 {
22245 for(int32_t j=0; j<MAPSCRS; j++)
22246 {
22247 for(int32_t m=0; m<32; m++)
22248 {
22249 if(combobuf[TheMaps[(i*MAPSCRS)+j].ffcs[m].data].type == cCHANGE)
22250 TheMaps[(i*MAPSCRS)+j].ffcs[m].flags|=ffCHANGER;
22251 }
22252 }
22253 }
22254 }
22255
22256
4/6
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 102 times.
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 29 times.
✗ Branch 5 not taken.
131 if(get_qr(qr_CONTFULL_DEP) && !get_bit(skip_flags, skip_rules) && !get_bit(skip_flags, skip_initdata))
22257 {
22258 29 set_qr(qr_CONTFULL_DEP, 0);
22259 29 zinit.flags.set(INIT_FL_CONTPERCENT,true);
22260 29 zinit.cont_heart=100;
22261 29 zinit.counter[crLIFE]=zinit.mcounter[crLIFE];
22262 29 }
22263
22264 131 box_out("Done.");
22265 131 box_eol();
22266 131 box_end(false);
22267
22268
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 131 times.
131 if(!get_bit(skip_flags, skip_header))
22269 {
22270 131 memcpy(Header, &tempheader, sizeof(tempheader));
22271 131 }
22272
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 131 times.
131 if(!get_bit(skip_flags, skip_zinfo))
22273 {
22274 131 ZI.copyFrom(tempzi);
22275 131 }
22276
22277
1/2
✓ Branch 0 taken 131 times.
✗ Branch 1 not taken.
131 if(get_bit(skip_flags, skip_maps))
22278 {
22279 map_count=old_map_count;
22280 }
22281
22282
1/2
✓ Branch 0 taken 131 times.
✗ Branch 1 not taken.
131 if(get_bit(skip_flags, skip_rules))
22283 {
22284 memcpy(quest_rules, old_quest_rules, QUESTRULES_NEW_SIZE);
22285 memcpy(extra_rules, old_extra_rules, EXTRARULES_SIZE);
22286 unpack_qrs();
22287 }
22288
22289
1/2
✓ Branch 0 taken 131 times.
✗ Branch 1 not taken.
131 if(get_bit(skip_flags, skip_midis))
22290 {
22291 memcpy(midi_flags, old_midi_flags, MIDIFLAGS_SIZE);
22292 }
22293
22294
2/2
✓ Branch 0 taken 127 times.
✓ Branch 1 taken 4 times.
131 if( FFCore.quest_format[vZelda] < 0x210 )
22295 {
22296 4 zprint2("\n[QUEST METADATA]\n");
22297
22298
1/13
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
4 switch(FFCore.quest_format[vZelda])
22299 {
22300 case 0x193:
22301 {
22302 zprint2("Last saved in version: 1.93, Beta %d\n", FFCore.quest_format[vBuild]); break;
22303 }
22304 case 0x192:
22305 {
22306 zprint2("Last saved in version: 1.92, Beta %d\n", FFCore.quest_format[vBuild]); break;
22307 }
22308 case 0x190:
22309 {
22310 4 zprint2("Last saved in version: 1.90");
22311
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22312 4 else zprint2("\n");
22313 4 break;
22314 }
22315 case 0x188:
22316 {
22317 zprint2("Last saved in version: 1.88");
22318 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22319 else zprint2("\n");
22320 break;
22321 }
22322 case 0x187:
22323 {
22324 zprint2("Last saved in version: 1.87");
22325 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22326 else zprint2("\n");
22327 break;
22328 }
22329 case 0x186:
22330 {
22331 zprint2("Last saved in version: 1.86");
22332 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22333 else zprint2("\n");
22334 break;
22335 }
22336 case 0x185:
22337 {
22338 zprint2("Last saved in version: 1.85");
22339 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22340 else zprint2("\n");
22341 break;
22342 }
22343 case 0x184:
22344 {
22345 zprint2("Last saved in version: 1.84");
22346 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22347 else zprint2("\n");
22348 break;
22349 }
22350 case 0x183:
22351 {
22352 zprint2("Last saved in version: 1.83");
22353 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22354 else zprint2("\n");
22355 break;
22356 }
22357 case 0x182:
22358 {
22359 zprint2("Last saved in version: 1.82");
22360 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22361 else zprint2("\n");
22362 break;
22363 }
22364 case 0x181:
22365 {
22366 zprint2("Last saved in version: 1.81");
22367 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22368 else zprint2("\n");
22369 break;
22370 }
22371 case 0x180:
22372 {
22373 zprint2("Last saved in version: 1.80");
22374 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22375 else zprint2("\n");
22376 break;
22377 }
22378 default:
22379 {
22380 zprint2("Last saved in version: %x, Beta %d\n", FFCore.quest_format[vZelda],FFCore.quest_format[vBuild]); break;
22381 }
22382 }
22383 4 }
22384
22385
1/2
✓ Branch 0 taken 131 times.
✗ Branch 1 not taken.
131 if(loading_tileset_flags & TILESET_CLEARMAPS)
22386 {
22387 TheMaps.clear();
22388 TheMaps.resize(MAPSCRS*1);
22389 map_count = 1;
22390 map_autolayers.clear();
22391 map_autolayers.resize(6*1);
22392 for(size_t i = 0; i < MAPSCRS; ++i)
22393 {
22394 TheMaps[i].zero_memory();
22395 }
22396 }
22397
1/2
✓ Branch 0 taken 131 times.
✗ Branch 1 not taken.
131 if(loading_tileset_flags & TILESET_CLEARHEADER)
22398 {
22399 memset(Header->password, 0, sizeof(Header->password));
22400 memset(Header->minver, 0, sizeof(Header->minver));
22401 memset(Header->title, 0, sizeof(Header->title));
22402 memset(Header->author, 0, sizeof(Header->author));
22403 memset(Header->version, 0, sizeof(Header->version));
22404 Header->use_keyfile = 0;
22405 Header->dirty_password = false;
22406 cvs_MD5Context ctx;
22407 cvs_MD5Init(&ctx);
22408 cvs_MD5Update(&ctx, (const uint8_t*)"", 0);
22409 cvs_MD5Final(Header->pwd_hash, &ctx);
22410 }
22411
22412 131 return qe_OK;
22413
22414 invalid:
22415 box_out("error.");
22416 box_eol();
22417 box_end(true);
22418
22419 if(f)
22420 {
22421 pack_fclose(f);
22422 }
22423
22424 if(!oldquest)
22425 {
22426 if(exists(tmpfilename))
22427 {
22428 delete_file(tmpfilename);
22429 }
22430 }
22431
22432 return qe_invalid;
22433
22434 131 }
22435
22436 static bool _is_loading_quest;
22437
22438 bool is_loading_quest()
22439 {
22440 return _is_loading_quest;
22441 }
22442
22443 131 int32_t loadquest(const char *filename, zquestheader *Header, miscQdata *Misc,
22444 zctune *tunes, bool show_progress, byte *skip_flags, byte printmetadata,
22445 bool report, byte qst_num, dword tilesetflags)
22446 {
22447 131 loading_tileset_flags = tilesetflags;
22448 131 const char* basename = get_filename(filename);
22449 131 zapp_reporting_add_breadcrumb("load_quest", basename);
22450 131 zapp_reporting_set_tag("qst.filename", basename);
22451
22452 131 loading_qst_name = filename;
22453 131 loading_qst_num = qst_num;
22454 // In CI, builds are cached for replay tests, which can result in their build dates being earlier than what it would be locally.
22455 // So to avoid a more-recently updated .qst file from hitting the "last saved in a newer version" prompt, we disable in CI.
22456
1/2
✓ Branch 0 taken 131 times.
✗ Branch 1 not taken.
131 if (!is_ci())
22457 loadquest_report = report;
22458
22459 131 _is_loading_quest = true;
22460 131 auto start = std::chrono::steady_clock::now();
22461 131 int32_t ret = _lq_int(filename, Header, Misc, tunes, show_progress, skip_flags, printmetadata);
22462 131 int32_t load_ms = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::steady_clock::now() - start).count();
22463 131 zprint2("Time to load qst: %d ms\n", load_ms);
22464 131 _is_loading_quest = false;
22465
22466
1/2
✓ Branch 0 taken 131 times.
✗ Branch 1 not taken.
131 if(show_progress)
22467 {
22468 if(ret)
22469 {
22470 box_out("-- Error loading quest file! --");
22471 box_end(true);
22472 }
22473 else box_end(false);
22474 }
22475
22476 131 load_tmp_zi = NULL;
22477 131 loading_qst_name = NULL;
22478 131 loadquest_report = false;
22479 131 loading_qst_num = 0;
22480
22481 131 zapp_reporting_set_tag("qst.title", Header->title);
22482 131 zapp_reporting_set_tag("qst.zc_version", Header->getVerStr());
22483
22484 131 return ret;
22485 }
22486